Difference between revisions of "Sprite"

From GiderosMobile
(Created page with "__NOTOC__ '''Supported platforms:''' <br/> '''Available since:''' Gideros 2011.6<br/> === Description === <br /> The `Sprite` class is the base class for all objects that can...")
 
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''Supported platforms:''' <br/>
+
'''Supported platforms:''' android, ios, mac, pc<br/>
 
'''Available since:''' Gideros 2011.6<br/>
 
'''Available since:''' Gideros 2011.6<br/>
 
=== Description ===
 
=== Description ===
Line 9: Line 9:
 
The drawing order is defined by the order of children. First child is drawn first and last child is drawn last. It is possible to change the drawing order by modifying the order of child list.<br />
 
The drawing order is defined by the order of children. First child is drawn first and last child is drawn last. It is possible to change the drawing order by modifying the order of child list.<br />
 
A `Sprite` instance can exists without attaching the scene tree.<br />
 
A `Sprite` instance can exists without attaching the scene tree.<br />
An unattached sprite can receive `Event.ENTER_FRAME` event but it will only receive mouse and touch events when it is attached to the scene tree.<br />{|-
+
An unattached sprite can receive `Event.ENTER_FRAME` event but it will only receive mouse and touch events when it is attached to the scene tree.<br />
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
{|-
 
| style="width: 50%;"|
 
| style="width: 50%;"|
 
=== Methods ===
 
=== Methods ===
 +
[[Sprite.new]] - creates a new Sprite object<br/>
 +
[[Sprite:addChild]] - adds a sprite as a child<br/>
 +
[[Sprite:addChildAt]] - add a sprite as a child at the index position specified<br/>
 +
[[Sprite:clearBlendMode]] - clears the blending mode<br/>
 +
[[Sprite:contains]] - determines whether the specified sprite is contained in the subtree of this sprite<br/>
 +
[[Sprite:get]] - gets the specified property by its name<br/>
 +
[[Sprite:getAlpha]] - returns the alpha transparency of this sprite<br/>
 +
[[Sprite:getAnchorPosition]] - Returns anchor position of Sprite<br/>
 +
[[Sprite:getBounds]] - returns the bounds as it appears in another sprite's coordinate system<br/>
 +
[[Sprite:getChildAt]] - returns the child sprite that exists at the specified index<br/>
 +
[[Sprite:getChildIndex]] - returns the index of the specified child sprite<br/>
 +
[[Sprite:getClip]] - <br/>
 +
[[Sprite:getColorTransform]] - returns the red, green, blue and alpha channel multipliers<br/>
 +
[[Sprite:getHeight]] - returns the height<br/>
 +
[[Sprite:getMatrix]] - returns the transformation matrix of the sprite<br/>
 +
[[Sprite:getNumChildren]] - returns the number of children of this sprite<br/>
 +
[[Sprite:getParent]] - returns the parent sprite<br/>
 +
[[Sprite:getPosition]] - gets the x,y and z coordinates of the sprite<br/>
 +
[[Sprite:getRotation]] - returns the rotation of the sprite in degrees<br/>
 +
[[Sprite:getRotationX]] - returns the rotation of the sprite around x axis in degrees<br/>
 +
[[Sprite:getRotationY]] - returns the rotation of the sprite around y axis in degrees<br/>
 +
[[Sprite:getScale]] - returns the horizontal, vertical and z scales of the sprite<br/>
 +
[[Sprite:getScaleX]] - returns the horizontal scale of the sprite<br/>
 +
[[Sprite:getScaleY]] - returns the vertical scale of the sprite<br/>
 +
[[Sprite:getScaleZ]] - returns the scale on z axis of the sprite<br/>
 +
[[Sprite:getSkew]] - <br/>
 +
[[Sprite:getSkewX]] - <br/>
 +
[[Sprite:getSkewY]] - <br/>
 +
[[Sprite:getWidth]] - returns the width<br/>
 +
[[Sprite:getX]] - returns the x coordinate of the sprite<br/>
 +
[[Sprite:getY]] - returns the y coordinate of the sprite<br/>
 +
[[Sprite:getZ]] - returns the z coordinate of the sprite<br/>
 +
[[Sprite:globalToLocal]] - converts the x,y coordinates from the global to the sprite's (local) coordinates<br/>
 +
[[Sprite:hitTestPoint]] - checks the given coordinates is in bounds of the sprite<br/>
 +
[[Sprite:isVisible]] - returns the visibility of sprite<br/>
 +
[[Sprite:localToGlobal]] - converts the x,y coordinates from the sprite's (local) coordinates to the global coordinates<br/>
 +
[[Sprite:removeChild]] - removes the child sprite<br/>
 +
[[Sprite:removeChildAt]] - removes the child sprite at the specifed index<br/>
 +
[[Sprite:removeFromParent]] - if the sprite has a parent, removes the sprite from the child list of its parent sprite.<br/>
 +
[[Sprite:set]] - sets the specified property by its name<br/>
 +
[[Sprite:setAlpha]] - sets the alpha transparency of this sprite<br/>
 +
[[Sprite:setAnchorPosition]] - Set anchor position<br/>
 +
[[Sprite:setBlendMode]] - sets the blend mode of the sprite<br/>
 +
[[Sprite:setClip]] - Clip Sprite contents<br/>
 +
[[Sprite:setColorTransform]] - sets the red, green, blue and alpha channel multipliers<br/>
 +
[[Sprite:setMatrix]] - sets the transformation matrix of the sprite<br/>
 +
[[Sprite:setPosition]] - sets the x,y and z coordinates of the sprite<br/>
 +
[[Sprite:setRotation]] - sets the rotation of the sprite in degrees<br/>
 +
[[Sprite:setRotationX]] - sets the rotation of the sprite in degrees around x axis<br/>
 +
[[Sprite:setRotationY]] - sets the rotation of the sprite in degrees around y axis<br/>
 +
[[Sprite:setScale]] - sets the horizontal, vertical and z axis scales of the sprite<br/>
 +
[[Sprite:setScaleX]] - sets the horizontal scale of the sprite<br/>
 +
[[Sprite:setScaleY]] - sets the vertical scale of the sprite<br/>
 +
[[Sprite:setScaleZ]] - Set scale on z axis<br/>
 +
[[Sprite:setShader]] - Set shader for this sprite<br/>
 +
[[Sprite:setShaderConstant]] - Change the value of a uniform for this sprite<br/>
 +
[[Sprite:setSkew]] - <br/>
 +
[[Sprite:setSkewX]] - <br/>
 +
[[Sprite:setSkewY]] - <br/>
 +
[[Sprite:setStencilOperation]] - Set the stencil operation for this sprite<br/>
 +
[[Sprite:setVisible]] - sets the visibility of sprite<br/>
 +
[[Sprite:setX]] - sets the x coordinate of the sprite<br/>
 +
[[Sprite:setY]] - sets the y coordinate of the sprite<br/>
 +
[[Sprite:setZ]] - sets the z coordinate of the sprite<br/>
 +
[[Sprite:swapChildren]] - Swap two children index places<br/>
 +
[[Sprite:swapChildrenAt]] - Swaps two child sprites.<br/>
 
| style="width: 50%;"|
 
| style="width: 50%;"|
 
=== Events ===
 
=== Events ===
 +
[[Event.ADDED_TO_STAGE]]
 +
[[Event.ENTER_FRAME]]
 +
[[Event.KEY_DOWN]]
 +
[[Event.KEY_UP]]
 +
[[Event.LAYOUT_RESIZED]]
 +
[[Event.MOUSE_DOWN]]
 +
[[Event.MOUSE_HOVER]]
 +
[[Event.MOUSE_MOVE]]
 +
[[Event.MOUSE_UP]]
 +
[[Event.MOUSE_WHEEL]]
 +
[[Event.REMOVED_FROM_STAGE]]
 +
[[Event.TOUCHES_BEGIN]]
 +
[[Event.TOUCHES_CANCEL]]
 +
[[Event.TOUCHES_END]]
 +
[[Event.TOUCHES_MOVE]]
 
=== Constants ===
 
=== Constants ===
 +
[[Sprite.ADD]]
 +
[[Sprite.ALPHA]]
 +
[[Sprite.MULTIPLY]]
 +
[[Sprite.NO_ALPHA]]
 +
[[Sprite.SCREEN]]
 
|}
 
|}

Revision as of 09:57, 23 August 2018

Supported platforms: android, ios, mac, pc
Available since: Gideros 2011.6

Description


The `Sprite` class is the base class for all objects that can be placed on the scene tree. It is the basic scene tree building block.
A sprite can contain child sprites which makes the scene tree hierarchy. Transformations such as translation, rotation, scaling and color transforms propogates its effect to all of its children.
The drawing order is defined by the order of children. First child is drawn first and last child is drawn last. It is possible to change the drawing order by modifying the order of child list.
A `Sprite` instance can exists without attaching the scene tree.
An unattached sprite can receive `Event.ENTER_FRAME` event but it will only receive mouse and touch events when it is attached to the scene tree.














































Methods

Sprite.new - creates a new Sprite object
Sprite:addChild - adds a sprite as a child
Sprite:addChildAt - add a sprite as a child at the index position specified
Sprite:clearBlendMode - clears the blending mode
Sprite:contains - determines whether the specified sprite is contained in the subtree of this sprite
Sprite:get - gets the specified property by its name
Sprite:getAlpha - returns the alpha transparency of this sprite
Sprite:getAnchorPosition - Returns anchor position of Sprite
Sprite:getBounds - returns the bounds as it appears in another sprite's coordinate system
Sprite:getChildAt - returns the child sprite that exists at the specified index
Sprite:getChildIndex - returns the index of the specified child sprite
Sprite:getClip -
Sprite:getColorTransform - returns the red, green, blue and alpha channel multipliers
Sprite:getHeight - returns the height
Sprite:getMatrix - returns the transformation matrix of the sprite
Sprite:getNumChildren - returns the number of children of this sprite
Sprite:getParent - returns the parent sprite
Sprite:getPosition - gets the x,y and z coordinates of the sprite
Sprite:getRotation - returns the rotation of the sprite in degrees
Sprite:getRotationX - returns the rotation of the sprite around x axis in degrees
Sprite:getRotationY - returns the rotation of the sprite around y axis in degrees
Sprite:getScale - returns the horizontal, vertical and z scales of the sprite
Sprite:getScaleX - returns the horizontal scale of the sprite
Sprite:getScaleY - returns the vertical scale of the sprite
Sprite:getScaleZ - returns the scale on z axis of the sprite
Sprite:getSkew -
Sprite:getSkewX -
Sprite:getSkewY -
Sprite:getWidth - returns the width
Sprite:getX - returns the x coordinate of the sprite
Sprite:getY - returns the y coordinate of the sprite
Sprite:getZ - returns the z coordinate of the sprite
Sprite:globalToLocal - converts the x,y coordinates from the global to the sprite's (local) coordinates
Sprite:hitTestPoint - checks the given coordinates is in bounds of the sprite
Sprite:isVisible - returns the visibility of sprite
Sprite:localToGlobal - converts the x,y coordinates from the sprite's (local) coordinates to the global coordinates
Sprite:removeChild - removes the child sprite
Sprite:removeChildAt - removes the child sprite at the specifed index
Sprite:removeFromParent - if the sprite has a parent, removes the sprite from the child list of its parent sprite.
Sprite:set - sets the specified property by its name
Sprite:setAlpha - sets the alpha transparency of this sprite
Sprite:setAnchorPosition - Set anchor position
Sprite:setBlendMode - sets the blend mode of the sprite
Sprite:setClip - Clip Sprite contents
Sprite:setColorTransform - sets the red, green, blue and alpha channel multipliers
Sprite:setMatrix - sets the transformation matrix of the sprite
Sprite:setPosition - sets the x,y and z coordinates of the sprite
Sprite:setRotation - sets the rotation of the sprite in degrees
Sprite:setRotationX - sets the rotation of the sprite in degrees around x axis
Sprite:setRotationY - sets the rotation of the sprite in degrees around y axis
Sprite:setScale - sets the horizontal, vertical and z axis scales of the sprite
Sprite:setScaleX - sets the horizontal scale of the sprite
Sprite:setScaleY - sets the vertical scale of the sprite
Sprite:setScaleZ - Set scale on z axis
Sprite:setShader - Set shader for this sprite
Sprite:setShaderConstant - Change the value of a uniform for this sprite
Sprite:setSkew -
Sprite:setSkewX -
Sprite:setSkewY -
Sprite:setStencilOperation - Set the stencil operation for this sprite
Sprite:setVisible - sets the visibility of sprite
Sprite:setX - sets the x coordinate of the sprite
Sprite:setY - sets the y coordinate of the sprite
Sprite:setZ - sets the z coordinate of the sprite
Sprite:swapChildren - Swap two children index places
Sprite:swapChildrenAt - Swaps two child sprites.

Events

Event.ADDED_TO_STAGE Event.ENTER_FRAME Event.KEY_DOWN Event.KEY_UP Event.LAYOUT_RESIZED Event.MOUSE_DOWN Event.MOUSE_HOVER Event.MOUSE_MOVE Event.MOUSE_UP Event.MOUSE_WHEEL Event.REMOVED_FROM_STAGE Event.TOUCHES_BEGIN Event.TOUCHES_CANCEL Event.TOUCHES_END Event.TOUCHES_MOVE

Constants

Sprite.ADD Sprite.ALPHA Sprite.MULTIPLY Sprite.NO_ALPHA Sprite.SCREEN