Box2D Forums

It is currently Sat May 18, 2013 12:13 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Oct 23, 2011 11:40 am 
Offline

Joined: Sun Oct 23, 2011 11:31 am
Posts: 1
Hi!

I've been learning Box2d, WCK and AS3 for 2 weeks now and I'm building an Air Hockey Game for a school assignment that is to bo finished in 2 days.

I now need your help with the part where a player scores a goal.

When the puck(circle object) touches the goal(a rectangular movie clip) I want to reset the position of the puck and have it go back to the middle of the field.

What is the easiest way to do this? Using a hitTestObject and if then how?

Please give me an N00b-example ;)


Top
 Profile  
 
PostPosted: Sun Oct 30, 2011 5:53 pm 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
What you need to do is have a shape that defines the goal. Set reportBeginContact = true on the goal and listen for ContactEvent.BEGIN_CONTACT events. In your listener function, remove the puck from the stage, set it's x/y back to the starting position, then add it back to the stage.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group