Prerequisites:
- Use a current version of PushButton Engine.
- A properly initialized scene (see PBE Series: initializing your scene via ActionScript on how to setup it up)
There’s not much to say. We’ll just create an entity with a sprite render component – and position it in our scene.
//Create a new entity: var myEntity:IEntity = PBE.allocateEntity(); myEntity.initialize("MyEntity"); //Render component: var renderComp:SpriteRenderer = new SpriteRenderer(); renderComp.scene = PBE.getScene(); renderComp.fileName = "../assets/Images/platform.png"; renderComp.position = new Point(0, 0); renderComp.rotation = 0.0; //Add the component to the entity: myEntity.addComponent( renderComp, "Render" );
That’s the comfortable thing when working with PushButton Engine! You don’t necessary need a spatial component or such, just to display graphics. In case you wonder what a spatial component is: they’ll be covered in the next PBE Series tutorial!
Awesome post!