Difference between revisions of "Sprite:getBounds"

From GiderosMobile
(remove language stuff)
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Returns a rectangle (as x, y, width and height) that encloses the sprite as it appears in another sprite coordinate system.
 
Returns a rectangle (as x, y, width and height) that encloses the sprite as it appears in another sprite coordinate system.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
(number), (number), (number), (number) = Sprite:getBounds(targetSprite)
 
(number), (number), (number), (number) = Sprite:getBounds(targetSprite)
 
</source>
 
</source>
Line 19: Line 19:
  
 
=== Examples ===
 
=== Examples ===
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
local x, y, width, height = sprite:getBounds(sprite) -- returns local (untransformed) bounds
 
local x, y, width, height = sprite:getBounds(sprite) -- returns local (untransformed) bounds
 
local x, y, width, height = sprite:getBounds(stage) -- returns bounds as transformed to the stage coordinate system
 
local x, y, width, height = sprite:getBounds(stage) -- returns bounds as transformed to the stage coordinate system

Revision as of 15:31, 13 July 2023

Available since: Gideros 2011.6
Class: Sprite

Description

Returns a rectangle (as x, y, width and height) that encloses the sprite as it appears in another sprite coordinate system. <syntaxhighlight lang="lua"> (number), (number), (number), (number) = Sprite:getBounds(targetSprite) </source>

Parameters

targetSprite: (Sprite) the sprite that defines the other coordinate system to transform

Return values

Returns (number) x coordinate
Returns (number) y coordinate
Returns (number) width of Sprite
Returns (number) height of Sprite

Examples

<syntaxhighlight lang="lua"> local x, y, width, height = sprite:getBounds(sprite) -- returns local (untransformed) bounds local x, y, width, height = sprite:getBounds(stage) -- returns bounds as transformed to the stage coordinate system </source>