This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:guides:beginners:platforms_and_texture_repeating [2018/02/13 20:47 (7 years ago)] – ↷ Page moved from guides:beginners:platforms_and_texture_repeating to en:guides:beginners:platforms_and_texture_repeating iarwain | en:guides:beginners:platforms_and_texture_repeating [2024/11/17 03:22 (5 months ago)] (current) – sausage | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Part 8 – Platforms and Texture Repeating ====== | ====== Part 8 – Platforms and Texture Repeating ====== | ||
- | Our playfield will contain a number of platforms. What have we got in the current asset folders that would do for a platform? | + | Our playfield will contain a number of platforms. What have we got in the current |
{{ : | {{ : | ||
- | box.png. That' | + | '' |
+ | |||
+ | We' | ||
Start off with a single platform object: | Start off with a single platform object: | ||
Line 15: | Line 17: | ||
[PlatformObject] | [PlatformObject] | ||
Graphic | Graphic | ||
- | Position = (20, 470, 0) | + | Position = (-380, 170, 0) |
Scale = 2 | Scale = 2 | ||
</ | </ | ||
Line 21: | Line 23: | ||
And create it inside the Init() function with: | And create it inside the Init() function with: | ||
- | < | + | < |
+ | orxObject_CreateFromConfig(" | ||
orxObject_CreateFromConfig(" | orxObject_CreateFromConfig(" | ||
</ | </ | ||
Line 29: | Line 32: | ||
{{: | {{: | ||
- | Great. Next, the platform needs to be stretched out so that it acts like a platform and not just a simple box. You can do this by changing the scale property: | + | Great. Next, the platform needs to be stretched out so that it acts like a platform and not just a simple box. You can do this by changing the '' |
- | < | + | < |
[PlatformObject] | [PlatformObject] | ||
Graphic | Graphic | ||
- | Position = (20, 470, 0) | + | Position = (-380, 170, 0) |
Scale = (40, 2, 0) | Scale = (40, 2, 0) | ||
</ | </ | ||
Line 48: | Line 51: | ||
We also need the Repeat property, so that the texture will repeat within the object: | We also need the Repeat property, so that the texture will repeat within the object: | ||
- | < | + | < |
[PlatformObject] | [PlatformObject] | ||
Graphic | Graphic | ||
- | Position = (20, 470, 0) | + | Position = (-380, 170, 0) |
Scale = (40, 2, 0) | Scale = (40, 2, 0) | ||
Repeat | Repeat | ||
Line 66: | Line 69: | ||
Let's move the platform to the bottom of the screen and extend it to the whole screen width: | Let's move the platform to the bottom of the screen and extend it to the whole screen width: | ||
- | < | + | < |
[PlatformObject] | [PlatformObject] | ||
Graphic | Graphic | ||
- | Position = (0, 570, 0) | + | Position = (-400, 270, 0) |
Scale = (54, 2, 0) | Scale = (54, 2, 0) | ||
Repeat | Repeat | ||
Line 76: | Line 79: | ||
We can use this as a template to create many platforms. But rather than create a few platforms in code, it would be much easier to create a single empty parent object with a few child objects under it. | We can use this as a template to create many platforms. But rather than create a few platforms in code, it would be much easier to create a single empty parent object with a few child objects under it. | ||
- | Start by making | + | Start by re-using |
- | < | + | < |
[Scene] | [Scene] | ||
ChildList = PlatformObject # MiddlePlatformObject # TopLeftPlatformObject # | ChildList = PlatformObject # MiddlePlatformObject # TopLeftPlatformObject # | ||
</ | </ | ||
- | Anything added to a ChildList will become a child under the object, and will move with the parent. Its co-ordinates will be local under the parent. | + | Anything added to a '' |
- | Notice that PlatformObject is the only thing in the list that exists so far. Let's create others based on the settings of PlatformObject: | + | Notice that the '' |
< | < | ||
[MiddlePlatformObject@PlatformObject] | [MiddlePlatformObject@PlatformObject] | ||
- | Position = (250, 450, 0) | + | Position = (-150, 150, 0) |
- | Scale = (30, 2, 0) | + | Scale = (30, 2, 0) |
- | Repeat = (15, 1, 0) | + | Repeat |
[TopLeftPlatformObject@PlatformObject] | [TopLeftPlatformObject@PlatformObject] | ||
- | Position = (0, 320, 0) | + | Position = (-400, 20, 0) |
- | Scale = (14, 2, 0) | + | Scale = (14, 2, 0) |
- | Repeat = (7, 1, 0) | + | Repeat |
[TopPlatformObject@TopLeftPlatformObject] | [TopPlatformObject@TopLeftPlatformObject] | ||
- | Position = (300, 200, 0) | + | Position = (-100, -100, 0) |
[TopRightPlatformObject@TopLeftPlatformObject] | [TopRightPlatformObject@TopLeftPlatformObject] | ||
- | Position = (600, 90, 0) | + | Position = (200, -210, 0) |
</ | </ | ||
- | A quick explanation of the above syntax: MiddlePlatformObject and TopLeftPlatformObject inherit all four properties from PlatformObject and overrides three of them. TopPlatformObject and TopRightPlatformObject inherit properties from TopLeftPlatformObject, | + | A quick explanation of the above syntax: |
- | This is really to save configuration, | + | This is really to save on configuration, to be extensible, and to make things easier to change rather than copy and pasting the same details over and over. |
Next change the code in the Init() function to create " | Next change the code in the Init() function to create " | ||
- | < | + | < |
+ | orxObject_CreateFromConfig(" | ||
orxObject_CreateFromConfig(" | orxObject_CreateFromConfig(" | ||
</ | </ | ||
Line 125: | Line 129: | ||
---- | ---- | ||
- | Next, [[guides: | + | Next, [[en:guides: |
- | {{section> | + | {{section> |