SFML-2.3.2.2: SFML bindings

Safe HaskellNone
LanguageHaskell98

SFML.Graphics.Sprite

Synopsis

Documentation

module SFML.Utils

createSprite :: IO (Either SFException Sprite) Source

Create a new sprite.

copy :: SFCopyable a => a -> IO a Source

Copy the given SFML resource.

destroy :: SFResource a => a -> IO () Source

Destroy the given SFML resource.

setPosition :: SFTransformable a => a -> Vec2f -> IO () Source

Set the position of a transformable.

This function completely overwrites the previous position.

See move to apply an offset based on the previous position instead.

The default position of a transformable object is (0, 0).

setRotation Source

Arguments

:: SFTransformable a 
=> a 
-> Float

New rotation, in degrees

-> IO () 

Set the orientation of a transformable.

This function completely overwrites the previous rotation.

See rotate to add an angle based on the previous rotation instead.

The default rotation of a transformable SFTransformable object is 0.

setScale :: SFTransformable a => a -> Vec2f -> IO () Source

Set the scale factors of a transformable.

This function completely overwrites the previous scale.

See scale to add a factor based on the previous scale instead.

The default scale of a transformable SFTransformable object is (1, 1).

setOrigin :: SFTransformable a => a -> Vec2f -> IO () Source

Set the local origin of a transformable.

The origin of an object defines the center point for all transformations (position, scale, rotation).

The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation).

The default origin of a transformable SFTransformable object is (0, 0).

getPosition :: SFTransformable a => a -> IO Vec2f Source

Get the position of a transformable.

getRotation Source

Arguments

:: SFTransformable a 
=> a 
-> IO Float

Current rotation, in degrees

Get the orientation of a transformable.

getScale :: SFTransformable a => a -> IO Vec2f Source

Get the current scale of a transformable

getOrigin :: SFTransformable a => a -> IO Vec2f Source

Get the local origin of a transformable.

move :: SFTransformable a => a -> Vec2f -> IO () Source

Move a transformable by a given offset

This function adds to the current position of the object, unlike setPosition which overwrites it.

rotate Source

Arguments

:: SFTransformable a 
=> a 
-> Float

Angle of rotation, in degrees

-> IO () 

Rotate a transformable.

This function adds to the current rotation of the object, unlike setRotation which overwrites it.

scale :: SFTransformable a => a -> Vec2f -> IO () Source

Scale a transformable.

This function multiplies the current scale of the object, unlike setScale which overwrites it.

getTransform :: SFTransformable a => a -> IO Transform Source

Get the combined transform of a transformable.

getInverseTransform :: SFTransformable a => a -> IO Transform Source

Get the inverse of the combined transform of a transformable.

setColor :: Sprite -> Color -> IO () Source

Set the global color of a sprite.

This color is modulated (multiplied) with the sprite's texture. It can be used to colorize the sprite, or change its global opacity. By default, the sprite's color is opaque white.

getColor :: Sprite -> IO Color Source

Get the global color of a sprite.

setTexture Source

Arguments

:: SFTexturable a 
=> a 
-> Texture

New texture

-> Bool

Should the texture rect be reset to the size of the new texture?

-> IO () 

Change the source texture of a Texturable.

The texture argument refers to a texture that must exist as long as the texturable uses it. Indeed, the texturable doesn't store its own copy of the texture, but rather keeps a pointer to the one that you passed to this function.

If the source texture is destroyed and the texturable tries to use it, the behaviour is undefined.

If resetRect is True, the TextureRect property of the texturable is automatically adjusted to the size of the new texture. If it is false, the texture rect is left unchanged.

setTextureRect Source

Arguments

:: SFTexturable a 
=> a 
-> IntRect

Rectangle defining the region of the texture to display

-> IO () 

Set the sub-rectangle of the texture that a texturable will display.

The texture rect is useful when you don't want to display the whole texture, but rather a part of it.

By default, the texture rect covers the entire texture.

getTexture :: SFTexturable a => a -> IO (Maybe Texture) Source

Get the source texture of a texturable.

If the texturable has no source texture, Nothing is returned.

The returned pointer is const, which means that you can't modify the texture when you retrieve it with this function.

getTextureRect :: SFTexturable a => a -> IO IntRect Source

Get the sub-rectangle of the texture displayed by a texturable.

getLocalBounds :: SFBounded a => a -> IO FloatRect Source

Get the local bounding rectangle of a boundable.

The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.

getGlobalBounds :: SFBounded a => a -> IO FloatRect Source

Get the global bounding rectangle of a shape.

The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the sprite in the global 2D world's coordinate system.