Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-15-2009, 12:58 PM   #1
CmndrDemolition
Registered User
 
Join Date: Nov 2008
Posts: 7
Default [AS2] Scoring in Flash

I have two problems with a Flash project I'm working on. First off, I want for the score in my game to increase by one every time a certain object touches another. I set this up with a simple hitTest. However, I want this to be a one time thing (you bump into it once, score goes up by one). right now, if you stay over the intended object, the score continues to go up. how can you limit this?

Secondly, how can you have the Flash file go to a second frame if the score were to reach 100?
CmndrDemolition is offline   Reply With Quote
Old 12-15-2009, 03:00 PM   #2
neilmmm
Senior Member
 
neilmmm's Avatar
 
Join Date: Oct 2005
Location: dorset
Posts: 1,637
Default

outside your on EnterFrame

[CODE]var hitting:Boolean=false;
CODE]

within your hitTest

Code:
if (!hitting) {
	score++;
	score_txt.text=score;
	hitting=true;
}[/
when you stop hitTest set hitting back to false

so i guess you would have something like this

Code:
var hitting:Boolean = false;
score = 0;
mc.onPress = function() {
	this.startDrag();
	this.onEnterFrame = function() {
		if (this.hitTest(target)) {
			if (!hitting) {
				score++;
				score_txt.text = score;
				hitting = true;
			}
		} else {
			hitting = false;
		}
	};
};
neilmmm is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:55 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.