开发者

how to update a variable in actionscript 3?

开发者 https://www.devze.com 2023-02-20 16:38 出处:网络
i just st开发者_运维知识库arted learning actionscript 3 and i have a question. I am trying to create a game but i am not sure on how to create a global update for a variable? for example if i put this

i just st开发者_运维知识库arted learning actionscript 3 and i have a question. I am trying to create a game but i am not sure on how to create a global update for a variable? for example if i put this:

    myNumber+=1;
    txt.text = myNumber.toString();

It only updates once and stops when the game starts. I would like a constant update. How is this possible? is there an update() method this needs to go under?


import flash.events.Event;

addEventListener(Event.EnterFrame, HandleGameLoop);

function HandleGameLoop(e:Event):void
{
    // Everything in here will be called Every frame.
}

I suggest you look at a few tutorials given the questions you have asked. Here is a great one about games. It goes through the process from start to finish.

http://gamedev.michaeljameswilliams.com/

0

精彩评论

暂无评论...
验证码 换一张
取 消