Point Seclusion
Thursday April 18, 2024, 09:58:29 pm
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Post, Review, and Recruit
 
  Home Help Search Arcade Gallery Links Staff List Calendar Members Login Register  

HitTests don't work for me!

Pages: [1]   Go Down
  Print  
Author Topic: HitTests don't work for me!  (Read 620 times)
0 Members and 1 Guest are viewing this topic.
Elric
Newbie
*
Offline Offline

Posts: 7


View Profile
« on: Wednesday October 22, 2008, 02:50:33 am »

Hey guys, I am using Macromedia Flash 8, which uses ActionScript 2.0

All I can do is get the character to move, I cannot get it to collide with platforms, it just falls straight through.

Help would be EXTREMELY appreciated.
Report Spam   Report to moderator   Logged

Share on Facebook Share on Twitter

raider00321
Moderator
King
*****
Offline Offline

Newgrounds Alias: raider00321
Posts: 969


Mood:Not a happy chappy


View Profile
« Reply #1 on: Wednesday October 22, 2008, 02:54:21 am »

Hey guys, I am using Macromedia Flash 8, which uses ActionScript 2.0

All I can do is get the character to move, I cannot get it to collide with platforms, it just falls straight through.

Help would be EXTREMELY appreciated.

alright! help is what i want to give you! but need a bit more information. For instance, Could i please see the script your using hitTest as?
Report Spam   Report to moderator   Logged

V BEST FREE WEBHOST FOUND BY FAR V http://www.000webhost.com/89919.html
Elric
Newbie
*
Offline Offline

Posts: 7


View Profile
« Reply #2 on: Wednesday October 22, 2008, 02:58:33 am »

onClipEvent(load){
   falling = true;
}
onClipEvent(enterFrame){
   if(falling = true){
      this._y += 5;
   }else{
      this._y += 0;
   }
   if(Key.isDown(RIGHT)){
      this._x += 5;
   }
   if(Key.isDown(LEFT)){
      this._x -= 5;
   }
   if (_root.ground.hitTest(this._x, this._y, true)) {
      falling = false;
   }
}


(This is in a MovieClip called char, and there is another MovieClip called ground)
(Keep in mind I'm know basically nothing xD)
« Last Edit: Wednesday October 22, 2008, 02:59:49 am by Elric » Report Spam   Report to moderator   Logged
raider00321
Moderator
King
*****
Offline Offline

Newgrounds Alias: raider00321
Posts: 969


Mood:Not a happy chappy


View Profile
« Reply #3 on: Wednesday October 22, 2008, 03:18:04 am »

onClipEvent(load){
   falling = true;
}
onClipEvent(enterFrame){
   if(falling = true){
      this._y += 5;
   }else{
      this._y += 0;
   }
   if(Key.isDown(RIGHT)){
      this._x += 5;
   }
   if(Key.isDown(LEFT)){
      this._x -= 5;
   }
   if (_root.ground.hitTest(this._x, this._y, true)) {
      falling = false;
   }
}


(This is in a MovieClip called char, and there is another MovieClip called ground)
(Keep in mind I'm know basically nothing xD)


hmmm.... First of all... I'm not too sure you need the true statement Anyway, make sure the instance name of ground is ground. as for this._x and so on. try to fix it up with giving it a direct path such as _root.char._x and so on... if that doesn't work,l do you mind if you upload the fla file somewhere for me to check it?
Report Spam   Report to moderator   Logged

V BEST FREE WEBHOST FOUND BY FAR V http://www.000webhost.com/89919.html
Elric
Newbie
*
Offline Offline

Posts: 7


View Profile
« Reply #4 on: Wednesday October 22, 2008, 03:24:04 am »

http://rapidshare.com/files/156390341/collision.fla.html  << the file

I tried the _root.char._x stuff

I don't think flash likes me
Report Spam   Report to moderator   Logged
raider00321
Moderator
King
*****
Offline Offline

Newgrounds Alias: raider00321
Posts: 969


Mood:Not a happy chappy


View Profile
« Reply #5 on: Wednesday October 22, 2008, 03:28:41 am »

no, not at all. like i said, they didnt have an instance name. No biggie and very easy to forget to do :p

Doesnt matter for the char as much, but prolly best to give it the right name..

Ok.. so heres what you need to do...

1. Click on the ground movieClip, then where click on properties.

2.Once there you will see a white box with instance name in it. in that white box, give it the instance name ground.

YOu might want to do a similar thing with the char movieclip cept you would give it the instance name char.

Hope this helps Smiley
Report Spam   Report to moderator   Logged

V BEST FREE WEBHOST FOUND BY FAR V http://www.000webhost.com/89919.html
raider00321
Moderator
King
*****
Offline Offline

Newgrounds Alias: raider00321
Posts: 969


Mood:Not a happy chappy


View Profile
« Reply #6 on: Wednesday October 22, 2008, 03:34:21 am »

actually, that wasnt the only problem lol.  there were also problems with your code... ill post the proper code here in just a moment lol
Report Spam   Report to moderator   Logged

V BEST FREE WEBHOST FOUND BY FAR V http://www.000webhost.com/89919.html
Elric
Newbie
*
Offline Offline

Posts: 7


View Profile
« Reply #7 on: Wednesday October 22, 2008, 03:38:14 am »

Ohhh! Instance name is in properties, i thought it was just what you called the movieclip, thanx
Report Spam   Report to moderator   Logged
raider00321
Moderator
King
*****
Offline Offline

Newgrounds Alias: raider00321
Posts: 969


Mood:Not a happy chappy


View Profile
« Reply #8 on: Wednesday October 22, 2008, 03:40:56 am »

ok.. here it is
Code:
onClipEvent(load){
   falling = true;
}
onClipEvent(enterFrame){
   if(falling == true){/*notice the two equals signs. Remember, one equal sign is used for assigning values, two                equals signs checks variables values for equivilency and three equal signs  checks variables for strict equivilency*/
      this._y += 5;
   }else{
      this._y += 0;
   }
   if(Key.isDown(RIGHT)){
      this._x += 5;
   }
   if(Key.isDown(LEFT)){
      this._x -= 5;
   }
   if (this.hitTest(_root.ground)) {//ok, i moved this around a bit. what you had before wasn't really needed
      falling = false;
   }
}

Im not 100% sure, but i think you may have some problems with your movement script too..
Report Spam   Report to moderator   Logged

V BEST FREE WEBHOST FOUND BY FAR V http://www.000webhost.com/89919.html
raider00321
Moderator
King
*****
Offline Offline

Newgrounds Alias: raider00321
Posts: 969


Mood:Not a happy chappy


View Profile
« Reply #9 on: Wednesday October 22, 2008, 03:47:28 am »

yep, like i thought, you will have movement issues. you will need to use this to fix it instead of yours
Code:
if (Key.isDown(Key.LEFT)) {
_x -= 5;
}
Report Spam   Report to moderator   Logged

V BEST FREE WEBHOST FOUND BY FAR V http://www.000webhost.com/89919.html
Elric
Newbie
*
Offline Offline

Posts: 7


View Profile
« Reply #10 on: Wednesday October 22, 2008, 03:53:33 am »

*Praises*

You have NO idea how much you just helped me xD THANX
Report Spam   Report to moderator   Logged
raider00321
Moderator
King
*****
Offline Offline

Newgrounds Alias: raider00321
Posts: 969


Mood:Not a happy chappy


View Profile
« Reply #11 on: Wednesday October 22, 2008, 04:00:15 am »

haha no problem. if you need anymore help, feel free to drop by
Report Spam   Report to moderator   Logged

V BEST FREE WEBHOST FOUND BY FAR V http://www.000webhost.com/89919.html


Pages: [1]   Go Up
  Print  
 
Jump to:  

Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy