Skip to content

Commit

Permalink
Merge pull request godotengine#9909 from Calinou/using-servers-fix-co…
Browse files Browse the repository at this point in the history
…de-sample

Fix sprite position in code sample in Optimization using servers
  • Loading branch information
skyace65 authored Sep 5, 2024
2 parents b0c7081 + c504fc3 commit 11e0393
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tutorials/performance/using_servers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ This is an example of how to create a sprite from code and move it using the low
# Remember, keep this reference.
texture = load("res://my_texture.png")
# Add it, centered.
RenderingServer.canvas_item_add_texture_rect(ci_rid, Rect2(texture.get_size() / 2, texture.get_size()), texture)
RenderingServer.canvas_item_add_texture_rect(ci_rid, Rect2(-texture.get_size() / 2, texture.get_size()), texture)
# Add the item, rotated 45 degrees and translated.
var xform = Transform2D().rotated(deg_to_rad(45)).translated(Vector2(20, 30))
RenderingServer.canvas_item_set_transform(ci_rid, xform)
Expand All @@ -136,7 +136,7 @@ This is an example of how to create a sprite from code and move it using the low
// Remember, keep this reference.
_texture = ResourceLoader.Load<Texture2D>("res://MyTexture.png");
// Add it, centered.
RenderingServer.CanvasItemAddTextureRect(ciRid, new Rect2(_texture.GetSize() / 2, _texture.GetSize()), _texture.GetRid());
RenderingServer.CanvasItemAddTextureRect(ciRid, new Rect2(-_texture.GetSize() / 2, _texture.GetSize()), _texture.GetRid());
// Add the item, rotated 45 degrees and translated.
Transform2D xform = Transform2D.Identity.Rotated(Mathf.DegToRad(45)).Translated(new Vector2(20, 30));
RenderingServer.CanvasItemSetTransform(ciRid, xform);
Expand Down

0 comments on commit 11e0393

Please sign in to comment.