User Tools

Site Tools


guides:beginners:objects

Part 6 – Objects

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. One is available in the data\object assets folder called soldier.png:

First we need to create a graphic 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 = (50, 400, 0)
Scale    = 2

When a HeroObject is created in code, he will be placed at co-ordinates 50, 400 on the screen and scaled up 2x in size.

In code, replace the default object with ours:

orxObject_CreateFromConfig("HeroObject");

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\objects folder? The answer is in the [Resource] section:

[Resource]
Texture = ../data/object

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.


Next: Part 7 – Spritesheets and Animation.

guides/beginners/objects.txt · Last modified: 2017/05/30 05:50 (8 weeks ago) (external edit)