Sprite

From GiderosMobile

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
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.

Methods

Sprite.new creates a new Sprite object
Sprite:addChild adds a sprite as a child
Sprite:addChildAt adds a sprite as a child at the index position specified
Sprite:clearBlendMode clears the blending mode
Sprite:clone duplicate this sprite into an independant copy
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:getAnchorPoint returns anchor position
Sprite:getAnchorPosition returns anchor position
Sprite:getBounds returns the bounds as it appears in another sprite 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:getChildrenAtPoint returns the children sprites that corresponds to the given screen coordinates
Sprite:getClip returns the coordinates of the Sprite clip range if set with setClip
Sprite:getColorTransform returns the red, green, blue and alpha channel multipliers
Sprite:getDrawCount returns the number of Sprites actually drawn each frame on this subtree
Sprite:getHeight returns the height
Sprite:getLayoutConstraints gets the current layout constraints
Sprite:getLayoutInfo gets information of the current layout
Sprite:getLayoutParameters gets the current layout parameters
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:getSize returns the width and height of the Sprite
Sprite:getSkew returns the x and y skew parameters of the Sprite
Sprite:getSkewX returns the x skew parameters of the Sprite
Sprite:getSkewY returns the y skew parameters of the Sprite
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 (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 (local) coordinates to the global coordinates
Sprite:redrawEffects tells Gideros the effects must be recomputed
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:setAnchorPoint sets anchor position
Sprite:setAnchorPosition sets anchor position
Sprite:setBlendMode sets the blend mode of the sprite
Sprite:setClip clips Sprite contents
Sprite:setColorTransform sets the red, green, blue and alpha channel multipliers
Sprite:setEffectConstant changes the value of a constant in the effect stack
Sprite:setEffectStack associates an effect stack to this sprite
Sprite:setGhosts renders original Sprite with slight variations
Sprite:setLayoutConstraints specifies the child placement constraints for Gideros layout system
Sprite:setLayoutParameters specifies the parent parameters for Gideros layout system
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 sets scale on z axis
Sprite:setShader sets shader for this sprite
Sprite:setShaderConstant changes the value of a uniform for this sprite
Sprite:setSkew sets the skew (ie shear) of the Sprite
Sprite:setSkewX sets the Sprite x skew
Sprite:setSkewY sets the Sprite y skew
Sprite:setStencilOperation sets the stencil operation for this sprite
Sprite:setStopEventPropagation selects which events must not be propagated to parent 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:spriteToLocal converts from one sprite local space to another
Sprite:swapChildren swaps two children index places
Sprite:swapChildrenAt swaps two child sprites

Events

Event.ADDED_TO_STAGE
Event.ENTER_FRAME
Event.KEY_CHAR
Event.KEY_DOWN
Event.KEY_UP
Event.LAYOUT_RESIZED
Event.MOUSE_DOWN
Event.MOUSE_ENTER
Event.MOUSE_HOVER
Event.MOUSE_LEAVE
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.EFFECT_MODE_AUTOMATIC Beta feature
Sprite.EFFECT_MODE_CONTINUOUS Always update the effects, this is the default
Sprite.EFFECT_MODE_TRIGGERED Update effects on demand
Sprite.LAYOUT_ANCHOR_CENTER
Sprite.LAYOUT_ANCHOR_EAST
Sprite.LAYOUT_ANCHOR_NORTH
Sprite.LAYOUT_ANCHOR_NORTHEAST
Sprite.LAYOUT_ANCHOR_NORTHWEST
Sprite.LAYOUT_ANCHOR_SOUTH
Sprite.LAYOUT_ANCHOR_SOUTHEAST
Sprite.LAYOUT_ANCHOR_SOUTHWEST
Sprite.LAYOUT_ANCHOR_WEST
Sprite.LAYOUT_FILL_BOTH
Sprite.LAYOUT_FILL_HORIZONTAL
Sprite.LAYOUT_FILL_NONE
Sprite.LAYOUT_FILL_VERTICAL
Sprite.MULTIPLY
Sprite.NO_ALPHA
Sprite.SCREEN