Skip to content

Commit 11e0393

Browse files
authored
Merge pull request #9909 from Calinou/using-servers-fix-code-sample
Fix sprite position in code sample in Optimization using servers
2 parents b0c7081 + c504fc3 commit 11e0393

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tutorials/performance/using_servers.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ This is an example of how to create a sprite from code and move it using the low
114114
# Remember, keep this reference.
115115
texture = load("res://my_texture.png")
116116
# Add it, centered.
117-
RenderingServer.canvas_item_add_texture_rect(ci_rid, Rect2(texture.get_size() / 2, texture.get_size()), texture)
117+
RenderingServer.canvas_item_add_texture_rect(ci_rid, Rect2(-texture.get_size() / 2, texture.get_size()), texture)
118118
# Add the item, rotated 45 degrees and translated.
119119
var xform = Transform2D().rotated(deg_to_rad(45)).translated(Vector2(20, 30))
120120
RenderingServer.canvas_item_set_transform(ci_rid, xform)
@@ -136,7 +136,7 @@ This is an example of how to create a sprite from code and move it using the low
136136
// Remember, keep this reference.
137137
_texture = ResourceLoader.Load<Texture2D>("res://MyTexture.png");
138138
// Add it, centered.
139-
RenderingServer.CanvasItemAddTextureRect(ciRid, new Rect2(_texture.GetSize() / 2, _texture.GetSize()), _texture.GetRid());
139+
RenderingServer.CanvasItemAddTextureRect(ciRid, new Rect2(-_texture.GetSize() / 2, _texture.GetSize()), _texture.GetRid());
140140
// Add the item, rotated 45 degrees and translated.
141141
Transform2D xform = Transform2D.Identity.Rotated(Mathf.DegToRad(45)).Translated(new Vector2(20, 30));
142142
RenderingServer.CanvasItemSetTransform(ciRid, xform);

0 commit comments

Comments
 (0)