Topic was automatically imported from the old Question2Answer platform.
Asked By
MikeyZman
Not sure if what Im trying is legal. I have a long collisionshape2D that is a platform, and I’d like for it to look like a brick wall (think like mario bros platforms). I DL a brick texture (jpg) and assigned it to a sprite that is the same size as the collisionshape2D. I assumed that Godot would tile the texture repeatedly and I could size it until it spanned the sprite length, but it won’t and Im not even sure what Im trying is legal. My fix is several smaller square sprites (and appropriately scaled texture) that span the long collisionshape2D. To me this seems inefficient - or maybe it’s not? Thanks for help in Advance. below is my texture import log:
It’s probably easier to use a TextureRect for this:
Using A TextureRect
Create a TextureRect-node
Assign your image as its texture
Set expand to true
Set strech_mode to STRETCH_TILE / 2
Set rect_size to the dimensions you wish for
That said, if it has to be a Sprite, here you go:
Using A Sprite
Select your image in the “FileSystem”-Tab
Switch over to the “Import”-Tab (next to the “Scene”-Tab)
Set “Repeat” to “Enabled” and click “Reimport” (at the bottom)
Create a Sprite-node
Assign your image as its texture
Set region_enabled to true
Set region_rect to the dimensions you wish for
Thanks so much for the help. I am using 3.2 so I didn’t have the property selections that you indicated.
I did find a solution, however. My platform is 64pix deep x whatever length, Im going in even grid increments (64 pix reticules), so I resized my main texture to 64x64, created a TextureRect that was 64 pix thick and 64 x N blocks long and set the stretch mode to tile. That repeated the pattern. It works, and Ive learned several things just with struggling with this.
I used to make maps for Counter Strike years ago and I was used to being able to apply a texture to a polygon and size it in the editor, so I thought that would apply here. I’m sure it does and I am having success but maybe what I remember with mapping tools is not the same implementation here. Just gotta learn!
MikeyZman | 2020-02-22 19:29
I’m using 3.2 as well. I don’t know, what exactly you’re referring to by “property selections” here, but you’re probably just looking for it in the wrong place:
The “FileSystem”-Tab is by default in the lower-left of the window
The “Import”-Tab is by default in the upper-left of the window
Everything else is done in the “Inspector”, which is by default on the right side
Your solution equals the one I proposed under “Using A TextureRect”. What you describe from your Counter Strike days is possible by following the steps 1-3 from my second solution (titled “Using A Sprite”), then creating a Polygon2D-node and setting it’s texture-property to that image. It will fill out the Polygon completely (by repeating itself) and adapt accordingly, when you resize the Polygon later on.