how to create plateform of different sizes with a single tile while spawning

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sufiyandido
:warning: Old Version Published before Godot 3 was released.

i want to know how i can generate plateforms of different sizes by using a single tile for runner game through gdscript so that i could randomly spawn them

:bust_in_silhouette: Reply From: Zylann

If you are using a tilemap, you can set one, two or more cells next to each other to have the same tile ID, which will look like a single platform. For nice borders I suggest 3 tiles, one for the left edge, one for the right edge, and one for tiles in between. Then you can choose how many tiles width the platform has.
For scripting, take a look at TileMap functions: TileMap — Godot Engine (stable) documentation in English

If you don’t use a TileMap then you need to use a 3-slice approach, quite the same way. You would need a texture for left edge, one for right edge, and repeat-draw the middle part to fill the gap in between. The tilemap solution is a bit easier though.

i m trying to to with three slice approach
but using only one texture that “middle texture” .
i dnt know how i could repeat the texture for random nos

sufiyandido | 2017-07-25 11:54

It depends how you would it to look like. In general you really need 3 slices (it can be in a single texture though), but you’ll need 3 sprites, or 3 draw_rect(), and a rectangular collision shape to match.
Repeating the middle texture depends again how you want it to look like. If you use a separate texture, you can set it to repeat in the resource flags, then when used as a sprite or a draw_rect it will be able to tile along the width (if you provide the appropriate texture region). Otherwise it will stretch.

Zylann | 2017-07-25 18:59