Entity Creation (FlashPunk)

From Flash Game Dojo

Revision as of 04:39, 16 July 2010 by Reiss (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
More Snippets

To create a game object in FlashPunk, you have to create a class that extends Entity. A simple Entity might look like this:

import net.flashpunk.Entity;
public class MyEntity extends Entity
	public function MyEntity() 
	override public function update():void 
		// Put game logic here (movement, AI, input, etc).

Once you've done that, you can add an instance of it to your current World with the add() function.

FP.world.add(new MyEntity);

Once you've done this, the Entity's update() function will be called in the game loop, and you can assign it desired behaviour.

Personal tools