Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Score Timer.

Community Beginner ,
Sep 26, 2013 Sep 26, 2013

Hi,

I am fairly new to ActionScript and i have recently started making a game in which you dodge falling enimies.

Does anyone know how i would make the score constantly count up?

And then stop when i hit an enemy.

Thanks.

TOPICS
ActionScript
905
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 26, 2013 Sep 26, 2013

then use the timer class:

var t:Timer=new Timer(1000,0);

t.addEventListener(TimerEvent.TIMER,timeF);

t.start();

// use t.stop() when you hit an enemy

function timeF(e:TimerEvent):void{

// you can use t.currentCount

}

Translate
Community Expert ,
Sep 26, 2013 Sep 26, 2013

it's easiest to use a number or int variable to keep the current score. eg,

var score:int = 0;

// and whenever you want to increase the score, call incrementScoreF and pass the amount to increment.

function incrementScoreF(n:int):void{

score+=n;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 26, 2013 Sep 26, 2013

Thanks for the advice.

But all i really need is basically just a timer, counting up from 0.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 26, 2013 Sep 26, 2013

then use the timer class:

var t:Timer=new Timer(1000,0);

t.addEventListener(TimerEvent.TIMER,timeF);

t.start();

// use t.stop() when you hit an enemy

function timeF(e:TimerEvent):void{

// you can use t.currentCount

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 26, 2013 Sep 26, 2013

Thanks for the advice, this worked.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 26, 2013 Sep 26, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines