Difference between revisions of "Sprite"
(11 intermediate revisions by 2 users not shown) | |||
Line 12: | Line 12: | ||
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. | 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 the scene tree. | + | 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. | 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. | ||
Line 27: | Line 27: | ||
[[Sprite:get]] ''gets the specified property by its name''<br/><!--GIDEROSMTD:Sprite:get(param) gets the specified property by its name--> | [[Sprite:get]] ''gets the specified property by its name''<br/><!--GIDEROSMTD:Sprite:get(param) gets the specified property by its name--> | ||
[[Sprite:getAlpha]] ''returns the alpha transparency of this sprite''<br/><!--GIDEROSMTD:Sprite:getAlpha() returns the alpha transparency of this sprite--> | [[Sprite:getAlpha]] ''returns the alpha transparency of this sprite''<br/><!--GIDEROSMTD:Sprite:getAlpha() returns the alpha transparency of this sprite--> | ||
− | [[Sprite:getAnchorPosition]] ''returns anchor position | + | [[Sprite:getAnchorPoint]] ''returns anchor position''<br/><!--GIDEROSMTD:Sprite:getAnchorPoint() returns anchor position--> |
+ | [[Sprite:getAnchorPosition]] ''returns anchor position''<br/><!--GIDEROSMTD:Sprite:getAnchorPosition() returns anchor position--> | ||
[[Sprite:getBounds]] ''returns the bounds as it appears in another sprite coordinate system''<br/><!--GIDEROSMTD:Sprite:getBounds(targetSprite) returns the bounds as it appears in another sprite coordinate system--> | [[Sprite:getBounds]] ''returns the bounds as it appears in another sprite coordinate system''<br/><!--GIDEROSMTD:Sprite:getBounds(targetSprite) returns the bounds as it appears in another sprite coordinate system--> | ||
[[Sprite:getChildAt]] ''returns the child sprite that exists at the specified index''<br/><!--GIDEROSMTD:Sprite:getChildAt(index) returns the child sprite that exists at the specified index--> | [[Sprite:getChildAt]] ''returns the child sprite that exists at the specified index''<br/><!--GIDEROSMTD:Sprite:getChildAt(index) returns the child sprite that exists at the specified index--> | ||
Line 50: | Line 51: | ||
[[Sprite:getScaleY]] ''returns the vertical scale of the sprite''<br/><!--GIDEROSMTD:Sprite:getScaleY() returns the vertical scale of the sprite--> | [[Sprite:getScaleY]] ''returns the vertical scale of the sprite''<br/><!--GIDEROSMTD:Sprite:getScaleY() returns the vertical scale of the sprite--> | ||
[[Sprite:getScaleZ]] ''returns the scale on z axis of the sprite''<br/><!--GIDEROSMTD:Sprite:getScaleZ() returns the scale on z axis of the sprite--> | [[Sprite:getScaleZ]] ''returns the scale on z axis of the sprite''<br/><!--GIDEROSMTD:Sprite:getScaleZ() returns the scale on z axis of the sprite--> | ||
+ | [[Sprite:getSize]] returns the width and height of the Sprite<br/><!--GIDEROSMTD:Sprite:getSize() returns the width and height of the Sprite--> | ||
[[Sprite:getSkew]] returns the x and y skew parameters of the Sprite<br/><!--GIDEROSMTD:Sprite:getSkew() returns the x and y skew parameters of the Sprite--> | [[Sprite:getSkew]] returns the x and y skew parameters of the Sprite<br/><!--GIDEROSMTD:Sprite:getSkew() returns the x and y skew parameters of the Sprite--> | ||
[[Sprite:getSkewX]] returns the x skew parameters of the Sprite<br/><!--GIDEROSMTD:Sprite:getSkewX() returns the x skew parameters of the Sprite--> | [[Sprite:getSkewX]] returns the x skew parameters of the Sprite<br/><!--GIDEROSMTD:Sprite:getSkewX() returns the x skew parameters of the Sprite--> | ||
Line 58: | Line 60: | ||
[[Sprite:getZ]] ''returns the z coordinate of the sprite''<br/><!--GIDEROSMTD:Sprite:getZ() returns the z coordinate of the sprite--> | [[Sprite:getZ]] ''returns the z coordinate of the sprite''<br/><!--GIDEROSMTD:Sprite:getZ() returns the z coordinate of the sprite--> | ||
[[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, | + | [[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: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: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--> | ||
+ | [[Sprite:setAnchorPoint]] ''sets anchor position''<br/><!--GIDEROSMTD:Sprite:setAnchorPoint(anchorX,anchorY,anchorZ) sets anchor position--> | ||
[[Sprite:setAnchorPosition]] ''sets anchor position''<br/><!--GIDEROSMTD:Sprite:setAnchorPosition(anchorX,anchorY,anchorZ) sets anchor position--> | [[Sprite:setAnchorPosition]] ''sets anchor position''<br/><!--GIDEROSMTD:Sprite:setAnchorPosition(anchorX,anchorY,anchorZ) sets anchor position--> | ||
[[Sprite:setBlendMode]] ''sets the blend mode of the sprite''<br/><!--GIDEROSMTD:Sprite:setBlendMode(blendMode or src,dst) sets the blend mode of the sprite--> | [[Sprite:setBlendMode]] ''sets the blend mode of the sprite''<br/><!--GIDEROSMTD:Sprite:setBlendMode(blendMode or src,dst) sets the blend mode of the sprite--> | ||
Line 73: | Line 76: | ||
[[Sprite:setEffectConstant]] ''changes the value of a constant in the effect stack''<br/><!--GIDEROSMTD:Sprite:setEffectConstant(effectIndex,uniform name,data type,mult,data,program,variant) changes the value of a constant in the effect stack--> | [[Sprite:setEffectConstant]] ''changes the value of a constant in the effect stack''<br/><!--GIDEROSMTD:Sprite:setEffectConstant(effectIndex,uniform name,data type,mult,data,program,variant) changes the value of a constant in the effect stack--> | ||
[[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: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: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: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--> | ||
Line 103: | Line 108: | ||
[[Event.ADDED_TO_STAGE]]<br/><!--GIDEROSEVT:Event.ADDED_TO_STAGE addedToStage--> | [[Event.ADDED_TO_STAGE]]<br/><!--GIDEROSEVT:Event.ADDED_TO_STAGE addedToStage--> | ||
[[Event.ENTER_FRAME]]<br/><!--GIDEROSEVT:Event.ENTER_FRAME enterFrame--> | [[Event.ENTER_FRAME]]<br/><!--GIDEROSEVT:Event.ENTER_FRAME enterFrame--> | ||
+ | [[Event.KEY_CHAR]]<br/><!--GIDEROSEVT:Event.KEY_CHAR keyChar--> | ||
[[Event.KEY_DOWN]]<br/><!--GIDEROSEVT:Event.KEY_DOWN keyDown--> | [[Event.KEY_DOWN]]<br/><!--GIDEROSEVT:Event.KEY_DOWN keyDown--> | ||
[[Event.KEY_UP]]<br/><!--GIDEROSEVT:Event.KEY_UP keyUp--> | [[Event.KEY_UP]]<br/><!--GIDEROSEVT:Event.KEY_UP keyUp--> | ||
[[Event.LAYOUT_RESIZED]]<br/><!--GIDEROSEVT:Event.LAYOUT_RESIZED layout_resized--> | [[Event.LAYOUT_RESIZED]]<br/><!--GIDEROSEVT:Event.LAYOUT_RESIZED layout_resized--> | ||
[[Event.MOUSE_DOWN]]<br/><!--GIDEROSEVT:Event.MOUSE_DOWN mouseDown--> | [[Event.MOUSE_DOWN]]<br/><!--GIDEROSEVT:Event.MOUSE_DOWN mouseDown--> | ||
+ | [[Event.MOUSE_ENTER]]<br/><!--GIDEROSEVT:Event.MOUSE_ENTER mouseEnter--> | ||
[[Event.MOUSE_HOVER]]<br/><!--GIDEROSEVT:Event.MOUSE_HOVER mouseHover--> | [[Event.MOUSE_HOVER]]<br/><!--GIDEROSEVT:Event.MOUSE_HOVER mouseHover--> | ||
+ | [[Event.MOUSE_LEAVE]]<br/><!--GIDEROSEVT:Event.MOUSE_LEAVE mouseLeave--> | ||
[[Event.MOUSE_MOVE]]<br/><!--GIDEROSEVT:Event.MOUSE_MOVE mouseMove--> | [[Event.MOUSE_MOVE]]<br/><!--GIDEROSEVT:Event.MOUSE_MOVE mouseMove--> | ||
[[Event.MOUSE_UP]]<br/><!--GIDEROSEVT:Event.MOUSE_UP mouseUp--> | [[Event.MOUSE_UP]]<br/><!--GIDEROSEVT:Event.MOUSE_UP mouseUp--> | ||
Line 116: | Line 124: | ||
[[Event.TOUCHES_END]]<br/><!--GIDEROSEVT:Event.TOUCHES_END touchesEnd--> | [[Event.TOUCHES_END]]<br/><!--GIDEROSEVT:Event.TOUCHES_END touchesEnd--> | ||
[[Event.TOUCHES_MOVE]]<br/><!--GIDEROSEVT:Event.TOUCHES_MOVE touchesMove--> | [[Event.TOUCHES_MOVE]]<br/><!--GIDEROSEVT:Event.TOUCHES_MOVE touchesMove--> | ||
+ | |||
=== Constants === | === Constants === | ||
[[Sprite.ADD]]<br/><!--GIDEROSCST:Sprite.ADD add--> | [[Sprite.ADD]]<br/><!--GIDEROSCST:Sprite.ADD add--> | ||
[[Sprite.ALPHA]]<br/><!--GIDEROSCST:Sprite.ALPHA alpha--> | [[Sprite.ALPHA]]<br/><!--GIDEROSCST:Sprite.ALPHA alpha--> | ||
− | [[Sprite.EFFECT_MODE_AUTOMATIC]] '' | + | [[Sprite.EFFECT_MODE_AUTOMATIC]] ''Update effects automatic''<br/><!--GIDEROSCST:Sprite.EFFECT_MODE_AUTOMATIC 1--> |
− | [[Sprite.EFFECT_MODE_CONTINUOUS]] ''Always update the effects | + | [[Sprite.EFFECT_MODE_CONTINUOUS]] ''Always update the effects '''default'''''<br/><!--GIDEROSCST:Sprite.EFFECT_MODE_CONTINUOUS 0--> |
[[Sprite.EFFECT_MODE_TRIGGERED]] ''Update effects on demand''<br/><!--GIDEROSCST:Sprite.EFFECT_MODE_TRIGGERED 2--> | [[Sprite.EFFECT_MODE_TRIGGERED]] ''Update effects on demand''<br/><!--GIDEROSCST:Sprite.EFFECT_MODE_TRIGGERED 2--> | ||
[[Sprite.LAYOUT_ANCHOR_CENTER]]<br/><!--GIDEROSCST:Sprite.LAYOUT_ANCHOR_CENTER 0--> | [[Sprite.LAYOUT_ANCHOR_CENTER]]<br/><!--GIDEROSCST:Sprite.LAYOUT_ANCHOR_CENTER 0--> |
Latest revision as of 23:22, 6 October 2024
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 |