Hello guest! Login or Register
Construct 2 r90

Released Friday, May 11, 2012 at 2:01:09 PM

28mb for Windows XP, Vista & 7

Free Download
Download Manual

Coming Soon

Sprite


The Sprite object is an animatable image that appears in the game. It is one of the most important objects for most Construct 2 games. It is used to make most visual elements in a game, such as the player, enemies, projectiles, explosions and non-tiling scenery (tiled scenery is much better done with the Tiled Background object).

If a Sprite has a single animation with a single frame, it simply shows an image without animating. However, multiple animations can be added to Sprite objects with the Image and Animations editor.

All instances of Sprite objects share their animations. In other words, there is a single set of images comprising the animations which belongs to the object type, and these images are referenced by instances.

Sprite properties


Animations
Click the Edit link to open the Image and Animations editor for the object. All instances of the object type share a single set of animations.

Size
Click the Make 1:1 link to size the selection at original size (100%). This makes the width and height of the object the same as its first animation frame image.

Initial visibility
Set whether the object is shown (visible) or hidden (invisible) when the layout starts.

Initial frame
Set the initially displaying animation frame from the object's first animation. This is a zero-based index, so the first frame is 0. This can be useful for storing different tiles or scenery in different animation frames of a single Sprite object type.

Effect
Choose a blend mode for the object. (none) means the object displays normally over the background. Effects like explosions and lighting effects can be achieved with these blend modes. A demo of all the effects can be found here, or see the Sprite effects.capx project in the Examples folder in Construct 2's install directory.

Sprite conditions


For conditions in common to other objects, see Common conditions.

Compare frame
Compare the current animation frame number, which is a zero-based index (the first frame is 0).

Is flipped
Is mirrored
True if the object has been flipped or mirrored with the Set flipped or Set mirrored actions.

Is playing
True if a given animation is currently set. Animations are identified by their name (case insensitive).

On any finished
Triggered when any animation reaches the end. Looping animations do not finish.

On finished
Triggered when a given animation reaches the end. Looping animations do not finish. Animations are identified by their name (case insensitive).

On frame changed
Triggered whenever the animation switches to another frame while the animation is playing.

Is overlapping another object
Is overlapping at offset
True if any instance is overlapping any instance of another object. The collision polygons are taken in to account if set, as well as the object's size and rotation. The 'offset' variant will test for an overlap at an offset from the first object. For example, testing for an overlap at an offset of (100, 0) will temporarily move the object to the right 100 pixels, test for the overlap, then move it back again.

On collision with another object
Triggered upon the first time any instance starts overlapping any instance of another object. The collision polygons are taken in to account if set, as well as the object's size and rotation.

Sprite actions


For actions common to other objects, see Common actions.

Set animation
Change the currently playing animation to another animation. Animations are identified by their name (case insensitive). The new animation can either play from the beginning or from the same frame number as the last animation was on (current frame).

Set flipped
Set whether the object image appears vertically flipped or normal. This also affects image points and the collision polygon.

Set mirrored
Set whether the object image appears horizontally mirrored or normal. This is useful for platform games. Mirroring also affects image points and the collision polygon.

Set frame
Set the current zero-based animation frame number that is showing. The animation will continue to play at its current speed.

Set speed
Set the playback rate of the current animation, in animation frames per second. Instances can have different animation speeds.

Start
If the current animation is stopped, start playing the animation again. Playback can either resume from the current frame, or restart from the beginning.

Stop
Stop the current animation from playing. The object will be left showing the current animation frame.

Spawn another object
Create a new instance of a given object type. The new instance is created at the current object's position and also set to the same angle. The created object can be on any layer (chosen by its name or its zero-based number), and it can be positioned by an image point instead of the object's origin (chosen by its name or number). If a Family is created, a random object type in the family is picked.

Set scale
Sets the width and height to a multiple of the object's original size, similar to zooming the object proportionally. For example, if the object is 50x100, Set scale to 2 will set its size to 100x200, and Set scale to 0.1 will set its size to 5x10.

Sprite expressions


For expressions common to other objects, see common expressions.

AnimationFrame
The currently displaying zero-based animation frame number.

AnimationFrameCount
The number of animation frames in the current animation.

AnimationName
A string containing the name of the currently playing animation.

AnimationSpeed
The current playback rate of the current animation, in animation frames per second.

ImageWidth
ImageHeight
The original dimensions of the object (its current animation frame image size), in pixels. Since objects can be stretched at runtime causing the normal Width and Height expressions to return different values, these can be used to get the original size regardless of the stretched size.

Previous Entry
Particles
Next Entry
Text

Feedback on this page
How useful was this page for you?
Do you have any suggestions for this page?