Forums

ForumsProgramming Forum

I need help with AS3

Posted Mar 19, '12 at 10:55am

mightybob

mightybob

367 posts

I am working on a game where you need to avoid objects flying past you, I need code that will make it so if you hit the object it will go to a new scene/frame... if anyone can help that will be great!
I will also add your name to the credits if you like!

 

Posted Mar 19, '12 at 11:06am

Freckls627

Freckls627

33 posts

if(player.hitTestObject(Things Flying Past You))
{
gotoAndStop(Frame Number Here);
}

hitTestObject checks whether or not two objects are overlapping each other. If so this if statement just goes to the frame number you plug in. I assume you have multiple objects flying at you, so in that case you would need to throw a for loop around that if statement to cycle through all of the objects. Depending what class you are calling this from you may have to do this.

(parent as Document).gotoAndStop(Frame);

Assuming the Document class is the main class linked to your flash project.

I hope this helped.

 

Posted Mar 20, '12 at 6:19pm

mightybob

mightybob

367 posts

i've played around with the code for a while but cannot seem to get it to work... here is what i've done:

if(Nyan.hitTestObject(toaster_dog))
{
gotoAndStop(1);
}

frame 1 is the menu

the things flying at you are all contained in a symbol, so i just put the code on that symbol.

thanks for trying anyways... if you see anything i did wrong please let me know!

 
Reply to I need help with AS3

You must be logged in to post a reply!