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