Sprites in Orx are called Objects. These are the heart of games in Orx.
Our platform game is going to need a hero. Let's replace the default object in our game with a hero object.
We will need a graphic image for the hero. There's one available over in the Orx project in object assets folder:
orx/tutorial/data/object. Look for
Copy this file into your
Next, we need to create a graphic in the config that knows about the soldier.png image:
[HeroGraphic] Texture = soldier.png
Next, let's create an actual object that will use the HeroGraphic:
[HeroObject] Graphic = HeroGraphic Position = (-350, 100, 0) Scale = 2
When a HeroObject is created in code, he will be placed at co-ordinates -350, 100 on the screen (from the center) and scaled up 2x in size.
In the Init() function, replace the default object with ours:
Compile and run. You should get the following:
So that's great! Now you might be wondering, how does
HeroGraphic know how to get
solder.png from the data/texture folder? The answer is in the
[Resource] Texture = ../data/texture
We can specify multiple paths here and we will do so further down the track.
So good job! Next step is to animate our soldier.