Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hitTest between to movie clips

Status
Not open for further replies.

martinb7

Programmer
Jan 5, 2003
235
GB
Hi, i am making a car game where you have a car(movieclip named car) and you drive it around using the arrow keys and when it hits a coin (movieclip called coin), i would like a text box called score to update by 1.

Any ideas??

Thanx

Martin
 
no just how to make the score + 1 when the car hits the coin. please include the code for the hitTest pls.

Thanx

Martin
 
Something like this should get you started:

Code:
onClipEvent (enterFrame) {
	(_root.car.hitTest(_root.coin))?_root.score++:null;
         }

frozenpeas
 
yes that works thanx ;)

BUT, i only want the score to +1 not keep increasing, and when the car (movieclip(car)) hits the coin, i would like the coin to randomise to a new postition

//random code if you need it for the coin//

Code:
coinposx = random(687.3);
	coinposy = random(461.0);
	coin._x = coinposx;
	coin._y = coinposy;

Any ideas??

Thanx

Martin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top