PDA

View Full Version : Platform ActionScript Help



Chimaera
03-23-2008, 09:08 AM
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
03-23-2008, 10:05 AM
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
03-23-2008, 11:05 AM
Brilliant.
Cheers mate, that bit of code just made my game lol.

Rather Cheesy
03-23-2008, 11:16 AM
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
03-23-2008, 12:42 PM
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.