Difference between revisions of "Sprite"
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
<!-- GIDEROSOBJ:Sprite --> | <!-- GIDEROSOBJ:Sprite --> | ||
− | '''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/> | + | '''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]][[File:Platform linux.png]]<br/> |
'''Available since:''' Gideros 2011.6<br/> | '''Available since:''' Gideros 2011.6<br/> | ||
'''Inherits from:''' [[EventDispatcher]]<br/> | '''Inherits from:''' [[EventDispatcher]]<br/> | ||
Line 22: | Line 22: | ||
[[Sprite:addChild]] ''adds a sprite as a child''<br/><!--GIDEROSMTD:Sprite:addChild(child) adds a sprite as a child--> | [[Sprite:addChild]] ''adds a sprite as a child''<br/><!--GIDEROSMTD:Sprite:addChild(child) adds a sprite as a child--> | ||
[[Sprite:addChildAt]] ''adds a sprite as a child at the index position specified''<br/><!--GIDEROSMTD:Sprite:addChildAt(child,index) adds a sprite as a child at the index position specified--> | [[Sprite:addChildAt]] ''adds a sprite as a child at the index position specified''<br/><!--GIDEROSMTD:Sprite:addChildAt(child,index) adds a sprite as a child at the index position specified--> | ||
+ | [[Sprite:addChildrenAt]] ''adds multiple sprites at once as children at the index positions specified''<br/><!--GIDEROSMTD:Sprite:addChildrenAt(table) adds multiple sprites at once as children at the index positions specified--> | ||
[[Sprite:clearBlendMode]] ''clears the blending mode''<br/><!--GIDEROSMTD:Sprite:clearBlendMode() clears the blending mode--> | [[Sprite:clearBlendMode]] ''clears the blending mode''<br/><!--GIDEROSMTD:Sprite:clearBlendMode() clears the blending mode--> | ||
[[Sprite:clone]] ''duplicate this sprite into an independant copy''<br/><!--GIDEROSMTD:Sprite:clone() duplicate this sprite into an independant copy--> | [[Sprite:clone]] ''duplicate this sprite into an independant copy''<br/><!--GIDEROSMTD:Sprite:clone() duplicate this sprite into an independant copy--> | ||
Line 61: | Line 62: | ||
[[Sprite:globalToLocal]] ''converts the x,y coordinates from the global to the sprite (local) coordinates''<br/><!--GIDEROSMTD:Sprite:globalToLocal(x,y) converts the x,y coordinates from the global to the sprite (local) coordinates--> | [[Sprite:globalToLocal]] ''converts the x,y coordinates from the global to the sprite (local) coordinates''<br/><!--GIDEROSMTD:Sprite:globalToLocal(x,y) converts the x,y coordinates from the global to the sprite (local) coordinates--> | ||
[[Sprite:hitTestPoint]] ''checks the given coordinates is in bounds of the sprite''<br/><!--GIDEROSMTD:Sprite:hitTestPoint(x,y,visible,ref) checks the given coordinates is in bounds of the sprite--> | [[Sprite:hitTestPoint]] ''checks the given coordinates is in bounds of the sprite''<br/><!--GIDEROSMTD:Sprite:hitTestPoint(x,y,visible,ref) checks the given coordinates is in bounds of the sprite--> | ||
+ | [[Sprite:isOnStage]] ''returns if the sprite is on stage''<br/><!--GIDEROSMTD:Sprite:isOnStage() returns if the sprite is on stage--> | ||
[[Sprite:isVisible]] ''returns the visibility of sprite''<br/><!--GIDEROSMTD:Sprite:isVisible() returns the visibility of sprite--> | [[Sprite:isVisible]] ''returns the visibility of sprite''<br/><!--GIDEROSMTD:Sprite:isVisible() returns the visibility of sprite--> | ||
[[Sprite:localToGlobal]] ''converts the x,y coordinates from the sprite (local) coordinates to the global coordinates''<br/><!--GIDEROSMTD:Sprite:localToGlobal(x,y) converts the x,y coordinates from the sprite (local) coordinates to the global coordinates--> | [[Sprite:localToGlobal]] ''converts the x,y coordinates from the sprite (local) coordinates to the global coordinates''<br/><!--GIDEROSMTD:Sprite:localToGlobal(x,y) converts the x,y coordinates from the sprite (local) coordinates to the global coordinates--> | ||
Line 67: | Line 69: | ||
[[Sprite:removeChildAt]] ''removes the child sprite at the specifed index''<br/><!--GIDEROSMTD:Sprite:removeChildAt(index) removes the child sprite at the specifed index--> | [[Sprite:removeChildAt]] ''removes the child sprite at the specifed index''<br/><!--GIDEROSMTD:Sprite:removeChildAt(index) 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''<br/><!--GIDEROSMTD:Sprite:removeFromParent() if the sprite has a parent, removes the sprite from the child list of its parent sprite--> | [[Sprite:removeFromParent]] ''if the sprite has a parent, removes the sprite from the child list of its parent sprite''<br/><!--GIDEROSMTD:Sprite:removeFromParent() if the sprite has a parent, removes the sprite from the child list of its parent sprite--> | ||
+ | [[Sprite:resolveStyle]] ''retrieves a reference from a styling table''<br/><!--GIDEROSMTD:Sprite:resolveStyle(reference,table) retrieves a reference from a styling table--> | ||
[[Sprite:set]] ''sets the specified property by its name''<br/><!--GIDEROSMTD:Sprite:set(param,value) sets the specified property by its name--> | [[Sprite:set]] ''sets the specified property by its name''<br/><!--GIDEROSMTD:Sprite:set(param,value) sets the specified property by its name--> | ||
[[Sprite:setAlpha]] ''sets the alpha transparency of this sprite''<br/><!--GIDEROSMTD:Sprite:setAlpha(alpha) sets the alpha transparency of this sprite--> | [[Sprite:setAlpha]] ''sets the alpha transparency of this sprite''<br/><!--GIDEROSMTD:Sprite:setAlpha(alpha) sets the alpha transparency of this sprite--> | ||
Line 77: | Line 80: | ||
[[Sprite:setEffectStack]] ''associates an effect stack to this sprite''<br/><!--GIDEROSMTD:Sprite:setEffectStack(effectStack,mode) associates an effect stack to this sprite--> | [[Sprite:setEffectStack]] ''associates an effect stack to this sprite''<br/><!--GIDEROSMTD:Sprite:setEffectStack(effectStack,mode) associates an effect stack to this sprite--> | ||
[[Sprite:setGhosts]] ''renders original Sprite with slight variations''<br/><!--GIDEROSMTD:Sprite:setGhosts(table) renders original Sprite with slight variations--> | [[Sprite:setGhosts]] ''renders original Sprite with slight variations''<br/><!--GIDEROSMTD:Sprite:setGhosts(table) renders original Sprite with slight variations--> | ||
+ | [[Sprite:setHiddenChildren]] ''hides children''<br/><!--GIDEROSMTD:Sprite:setHiddenChildren(table) hides children--> | ||
[[Sprite:setLayoutConstraints]] ''specifies the child placement constraints for Gideros layout system''<br/><!--GIDEROSMTD:Sprite:setLayoutConstraints(constraints) specifies the child placement constraints for Gideros layout system--> | [[Sprite:setLayoutConstraints]] ''specifies the child placement constraints for Gideros layout system''<br/><!--GIDEROSMTD:Sprite:setLayoutConstraints(constraints) specifies the child placement constraints for Gideros layout system--> | ||
[[Sprite:setLayoutParameters]] ''specifies the parent parameters for Gideros layout system''<br/><!--GIDEROSMTD:Sprite:setLayoutParameters(layout) specifies the parent parameters for Gideros layout system--> | [[Sprite:setLayoutParameters]] ''specifies the parent parameters for Gideros layout system''<br/><!--GIDEROSMTD:Sprite:setLayoutParameters(layout) specifies the parent parameters for Gideros layout system--> | ||
Line 95: | Line 99: | ||
[[Sprite:setStencilOperation]] ''sets the stencil operation for this sprite''<br/><!--GIDEROSMTD:Sprite:setStencilOperation(mask) sets the stencil operation for this sprite--> | [[Sprite:setStencilOperation]] ''sets the stencil operation for this sprite''<br/><!--GIDEROSMTD:Sprite:setStencilOperation(mask) sets the stencil operation for this sprite--> | ||
[[Sprite:setStopEventPropagation]] ''selects which events must not be propagated to parent sprite''<br/><!--GIDEROSMTD:Sprite:setStopEventPropagation(mask) selects which events must not be propagated to parent sprite--> | [[Sprite:setStopEventPropagation]] ''selects which events must not be propagated to parent sprite''<br/><!--GIDEROSMTD:Sprite:setStopEventPropagation(mask) selects which events must not be propagated to parent sprite--> | ||
+ | [[Sprite:setStyle]] ''styling support''<br/><!--GIDEROSMTD:Sprite:setStyle(table) styling support--> | ||
[[Sprite:setVisible]] ''sets the visibility of sprite''<br/><!--GIDEROSMTD:Sprite:setVisible(visible) sets the visibility of sprite--> | [[Sprite:setVisible]] ''sets the visibility of sprite''<br/><!--GIDEROSMTD:Sprite:setVisible(visible) sets the visibility of sprite--> | ||
+ | [[Sprite:setWorldAlign]] ''aligns the Sprite position on a screen pixel''<br/><!--GIDEROSMTD:Sprite:setWorldAlign(boolean) aligns the Sprite position on a screen pixel--> | ||
[[Sprite:setX]] ''sets the x coordinate of the sprite''<br/><!--GIDEROSMTD:Sprite:setX(x) sets the x coordinate of the sprite--> | [[Sprite:setX]] ''sets the x coordinate of the sprite''<br/><!--GIDEROSMTD:Sprite:setX(x) sets the x coordinate of the sprite--> | ||
[[Sprite:setY]] ''sets the y coordinate of the sprite''<br/><!--GIDEROSMTD:Sprite:setY(y) sets the y coordinate of the sprite--> | [[Sprite:setY]] ''sets the y coordinate of the sprite''<br/><!--GIDEROSMTD:Sprite:setY(y) sets the y coordinate of the sprite--> | ||
[[Sprite:setZ]] ''sets the z coordinate of the sprite''<br/><!--GIDEROSMTD:Sprite:setZ(z) sets the z coordinate of the sprite--> | [[Sprite:setZ]] ''sets the z coordinate of the sprite''<br/><!--GIDEROSMTD:Sprite:setZ(z) sets the z coordinate of the sprite--> | ||
[[Sprite:spriteToLocal]] ''converts from one sprite local space to another''<br/><!--GIDEROSMTD:Sprite:spriteToLocal(spr,x,y,z,tx,ty,tz) converts from one sprite local space to another--> | [[Sprite:spriteToLocal]] ''converts from one sprite local space to another''<br/><!--GIDEROSMTD:Sprite:spriteToLocal(spr,x,y,z,tx,ty,tz) converts from one sprite local space to another--> | ||
+ | [[Sprite:spriteToLocalMatrix]] ''converts from one sprite local matrix space to another''<br/><!--GIDEROSMTD:Sprite:spriteToLocalMatrix(spr) converts from one sprite local matrix space to another--> | ||
[[Sprite:swapChildren]] ''swaps two children index places''<br/><!--GIDEROSMTD:Sprite:swapChildren(child1,child2) swaps two children index places--> | [[Sprite:swapChildren]] ''swaps two children index places''<br/><!--GIDEROSMTD:Sprite:swapChildren(child1,child2) swaps two children index places--> | ||
[[Sprite:swapChildrenAt]] ''swaps two child sprites''<br/><!--GIDEROSMTD:Sprite:swapChildrenAt(index1,index2) swaps two child sprites--> | [[Sprite:swapChildrenAt]] ''swaps two child sprites''<br/><!--GIDEROSMTD:Sprite:swapChildrenAt(index1,index2) swaps two child sprites--> | ||
+ | [[Sprite:updateStyle]] ''updates current style''<br/><!--GIDEROSMTD:Sprite:updateStyle() updates current style--> | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| |
Latest revision as of 19:55, 18 October 2025
Supported platforms:
Available since: Gideros 2011.6
Inherits from: EventDispatcher
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, propagate its effect to all of its children.
The drawing order is defined by the order of children. The first child is drawn first and the last child is drawn last. It is possible to change the drawing order by modifying the order of child list.
A Sprite instance can exist without attaching it to 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.
MethodsSprite.new creates a new Sprite object |
EventsEvent.ADDED_TO_STAGE ConstantsSprite.ADD |