User Tools

Site Tools


en:guides:beginners:objects

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
en:guides:beginners:objects [2018/02/14 04:47 (19 months ago)]
iarwain ↷ Links adapted because of a move operation
en:guides:beginners:objects [2018/06/27 12:15 (15 months ago)] (current)
sausage In line with init projects
Line 5: Line 5:
 Our platform game is going to need a hero. Let's replace the default object in our game with a hero object. 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:​+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 ''​soldier.png''​:
  
 {{ :​guides:​beginners:​soldier.png?​nolink&​64 |}} {{ :​guides:​beginners:​soldier.png?​nolink&​64 |}}
  
-First we need to create a graphic config that knows about the soldier.png image:+Copy this file into your ''​MyGame/​data/​texture''​ folder. 
 + 
 +Next, we need to create a graphic ​in the config that knows about the soldier.png image:
  
 <​code=ini>​ <​code=ini>​
Line 21: Line 23:
 [HeroObject] [HeroObject]
 Graphic ​ = HeroGraphic Graphic ​ = HeroGraphic
-Position = (50400, 0)+Position = (-350100, 0)
 Scale    = 2 Scale    = 2
 </​code>​ </​code>​
  
-When a HeroObject is created in code, he will be placed at co-ordinates ​50400 on the screen and scaled up 2x in size.+When a HeroObject is created in code, he will be placed at co-ordinates ​-350100 on the screen ​(from the center) ​and scaled up 2x in size.
  
-In code, replace the default object with ours:+In the Init() function, replace the default object with ours:
  
 <​code=cpp>​ <​code=cpp>​
Line 37: Line 39:
 {{:​guides:​beginners:​beginners-20-object-position.png?​nolink|}} {{:​guides:​beginners:​beginners-20-object-position.png?​nolink|}}
  
-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:+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]'' ​section:
  
 <​code=ini>​ <​code=ini>​
 [Resource] [Resource]
-Texture = ../data/object+Texture = ../data/texture
 </​code>​ </​code>​
  
en/guides/beginners/objects.txt · Last modified: 2018/06/27 12:15 (15 months ago) by sausage