Archive 17/01/2023.

Urho2D tiled sprites

Mike

A simple question, how to make the sprites tiled (repeating texture), for example for a background.

jmiller

Hi Mike,

Sprite2D::SetRectangle? urho3d.github.io/documentation/a00341.html
Default texture addressing mode is repeat.
Tiled * 10, centered

  Sprite2D@ bgs = cache.GetResource("Sprite2D", "Urho2D/Aster.png");
  bgs.rectangle = IntRect(0, 0, bgs.rectangle.width * 10, bgs.rectangle.height * 10);
  Node@ bgNode = scene_.CreateChild("StaticSprite2D");
  bgNode.position = Vector3(0.0f, 0.0f, 0.0f);

  StaticSprite2D@ bgStaticSprite = bgNode.CreateComponent("StaticSprite2D");
  bgStaticSprite.sprite = bgs;
aster2013

@carnalis Sprite2D::SetRectangle is used to set region in texture.

@ Mike:
Current you can create many StaticSprite as tiled background.
When tile-map added, you can use tile-map to create tiled background.