Platform ActionScript Help

Started by: Chimaera | Replies: 4 | Views: 745 | Closed

Chimaera
2

Posts: 2,490
Joined: Oct 2005
Rep: 10

View Profile
Mar 23, 2008 3:08 PM #98774
Hi guys, I'm making a platformer and I'm having trouble with some code, can anyone tell me how I can make the level change when my character hits a movieclip?

This is the code for the movieclip:
onClipEvent(enterFrame){
if(this.hitTest(_root.hero)){
_root.gotoAndStop(Frame2)
}
}


Can anyone tell me the following:
A) Why mien doesnt work.
B)How can I make it work.

Platformer made using the hitTest AS.
Scorpioxxx
2

Posts: 1,454
Joined: Apr 2006
Rep: 10

View Profile
Mar 23, 2008 4:05 PM #98825
Try:

onClipEvent(enterFrame){
if(_root.'the instance name instead of "this"'.hitTest(_root.hero)){
_root.gotoAndStop (2)
}
}

I changed everything I found that may have confused flash and you need to add the instance name.

Basicly, 'Frame2' is not a known variable to flash, only numbers represiting things are, so just '2', like the number 2 = March for spawning dates or something. Also try to avoid using 'this.' as AS3, if you move to it, doesn't support the bit of code and everything must be refered to by instance names.
Chimaera
2

Posts: 2,490
Joined: Oct 2005
Rep: 10

View Profile
Mar 23, 2008 5:05 PM #98897
Brilliant.
Cheers mate, that bit of code just made my game lol.
Rather Cheesy
2

Posts: 2,137
Joined: Apr 2007
Rep: 10

View Profile
Mar 23, 2008 5:16 PM #98906
Damn you Scorpio... I was gonna answer that! -_-

Aw well....

If you need future help Chimaera, I can help I'm pretty good at making platformers.
Scorpioxxx
2

Posts: 1,454
Joined: Apr 2006
Rep: 10

View Profile
Mar 23, 2008 6:42 PM #98985
Quote from Rather Cheesy
Damn you Scorpio... I was gonna answer that! -_-

Aw well....

If you need future help Chimaera, I can help I'm pretty good at making platformers.


^_^

But yea, you are good at platformers.