Sprite


Object Hierarchy:

Object hierarchy for Sprite

Description:

[ Compact ]
[ CCode ( cname = "sfSprite" , copy_function = "sfSprite_copy" , free_function = "sfSprite_destroy" ) ]
public class Sprite : Shape

Class representing a sprite, which is an object that can be drawn to the screen

A sprite is a graphical object that can be drawn to the screen. It has a texture which is the image that is displayed, and a position, which determines where the sprite is drawn. Sprites can also be rotated, scaled, and have their color changed.

Most (if not all) of you are already familiar with these two very common objects, so let's define them very briefly.

A texture is an image. But we call it "texture" because it has a very specific role: being mapped to a 2D entity.

A sprite is nothing more than a textured rectangle.

Ok, that was short but if you really don't understand what sprites and textures are, then you'll find a much better description on Wikipedia.

// Declare and load a texture
var texture = new texture.fromFile("texture.png");

// Create a sprite
var sprite = new Sprite();
sprite.setTexture(texture);
sprite.setTextureRect(IntRect(10, 10, 50, 30));
sprite.setColor(Color(255, 255, 255, 200));
sprite.setPosition(100, 25);

// Draw it
sprite.draw(window);


Namespace: sf
Package: sfml

Content:

Properties:

Creation methods:

Methods:

Inherited Members: