문제

This is probably a newb question, but let's assume I want to make a program that adds an entity every time I click.

My example code would be:

package
{
    import net.flashpunk.World;
    import net.flashpunk.utils.Input;

    public class MainWorld extends World
    {
        public function MainWorld()
        {
            trace("world started");
        }
        override public function update():void
        {
            if (Input.mousePressed) add(new blargEntity());
        }
    }
}

Now, there's an obvious problem with overriding the update function of the world: the world isn't updating anything.

Is there a way to do work in the World every frame?

도움이 되었습니까?

해결책

You would just need to add a super.update() call like so:

    override public function update():void
    {
        if (Input.mousePressed) add(new blargEntity());
        super.update();
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top