Component_Sprite Class
A sprite component to display an object on screen. It can be managed or unmanaged. A managed sprite is automatically added to the graphics-system and rendered every frame until it gets disposed. An unmanaged sprite needs to be added and removed manually.
Item Index
Methods
Methods
dispose
()
Disposes the sprite. If the sprite is managed, it will be automatically removed from the graphics system and viewport.
onDataBundleRestore.
-
Object
-
gs.ObjectCodecContext
Called if this object instance is restored from a data-bundle. It can be used re-assign event-handler, anonymous functions, etc.
Parameters:
-
Object
Objectdata - The data-bundle
-
gs.ObjectCodecContext
Objectcontext - The codec-context.
setup
()
Setup the sprite component. This method is automatically called by the system.
setupEventHandlers
()
Adds event-handlers for mouse/touch events
setupSprite
()
Setup the sprite.
update
()
Updates the sprite component by updating its visibility, image, padding and properties.
updateBitmap
()
Updates the bitmap object from the associated image name. The imageFolder property controls from which resource-folder the image will be loaded.
updateImage
()
Updates the image if the game object has the image-property set.
updateOptionalProperties
()
Updates the optional sprite properties from the game object properties.
updatePadding
()
Updates the padding.
updateProperties
()
Updates the sprite properties from the game object properties.
updateRect
()
Updates the source- and destination-rectangle of the game object so that the associated bitmap fits in. The imageHandling property controls how the rectangles are resized.
updateVideo
()
Updates the video object from the associated video name. It also updates the video-rendering process.
updateVisibility
()
If the sprite is unmanaged, this method will update the visibility of the sprite. If the sprite leaves the viewport, it will be removed to save performance and automatically added back to the viewport if it enters the viewport.
Properties
image
String
protected
The name of the image to display.
image
String
protected
The name of the folder from where the image should be loaded.
imageLoaded
Boolean
protected
Indicates if the image is loaded.
sprite
Sprite
protected
The native sprite object to display the game object on screen.
video
String
protected
The name of the video to display.
visible
Boolean
protected
The visibility. If false, the sprite is not rendered.