Solarus quests
1.6
Quest maker's reference
|
Drawable objects are things that can be drawn on a destination surface. They include the following types: surface, text surface and sprite. This page describes the methods common to those types.
These methods exist in all drawable types.
Draws this object on a destination surface.
dst_surface
(surface): The destination surface.x
(number, optional): X coordinate of where to draw this object (default 0
).y
(number, optional): Y coordinate of where to draw this object. (default 0
).Draws a subrectangle of this object on a destination surface.
region_x
(number): X coordinate of the subrectangle to draw.region_y
(number): Y coordinate of the subrectangle to draw.region_width
(number): Width of the subrectangle to draw.region_height
(number): Height of the subrectangle to draw.dst_surface
(surface): The destination surface.x
(number, optional): X coordinate of where to draw this rectangle on the destination surface (default 0
).y
(number, optional): Y coordinate of where to draw this rectangle. on the destination surface (default 0
).Returns the rotation angle of this object around its transformation origin. The rotation angle is in radians and goes in trigonometric direction.
0
means no rotation.Sets the rotation angle of this object around its transformation origin. The rotation angle is in radians and goes in trigonometric direction.
rotation
(number): The rotation angle in radians around the transformation origin. 0
means no rotation.Returns the scaling factors of this drawable object.
Set the scale factors for this drawable object. A scale of 1
corresponds to a normal size. A negative scale will flip the drawable in the corresponding axis. Scaling is performed around the transformation origin.
x
(number) : Scale factor in the X dimension.y
(number) : Scale factor in the Y dimension.Returns the transformation origin of this drawable object. The tranformation origin point is the pivot point used for rotation and scaling.
The transformation point is relative to the origin point of the drawable object, which is always the upper-left corner for surfaces and text surfaces, and the sprite origin point for sprites.
Set the transformation origin point of this drawable object. The tranformation origin point is the pivot point used for rotation and scaling.
The transformation point is relative to the origin point of the drawable object, which is always the upper-left corner for surfaces and text surfaces, and the sprite origin point for sprites.
x
(number): X coordinate of the transformation origin.y
(number): Y coordinate of the transformation origin.Returns the blend mode of this drawable object.
The blend mode defines how this drawable object will be drawn on other surfaces when you call drawable:draw() or drawable:draw_region().
Sets the blend mode of this drawable object.
The blend mode defines how this drawable object will be drawn on other surfaces when you call drawable:draw() or drawable:draw_region().
blend_mode
(string): The blend mode. Can be one of:"none"
: No blending. The destination surface is replaced by the pixels of this drawable object.dstRGBA = srcRGBA
"blend"
(default): This drawable object is alpha-blended onto the destination surface.dstRGB = (srcRGB * srcA) + (dstRGB * (1 - srcA))
dstA = srcA + (dstA * (1 - srcA))
"add"
: This drawable object is drawn onto the destination surface with additive blending. The clarity of the destination surface is kept. Useful to color and lighten the destination surface.dstRGB = (srcRGB * srcA) + dstRGB
"multiply"
: Color modulation. Can be used to darken the destination surface without degrading its content.dstRGB = srcRGB * dstRGB
Returns the shader applied to this object.
nil
if no shader is set.Sets the shader used to draw this object.
Default drawing is done with no shader.
shader
(shader): The shader to set, or nil
to reset drawing to normal.Returns the opacity of this drawable.
0
(transparent) to 255
(opaque).Sets the opacity of this drawable.
All drawables are initially opaque.
opacity
(integer): The opacity: 0
(transparent) to 255
(opaque).Returns the color multiplier of this drawable.
Sets the color modulator of this drawable, default is plain white {255,255,255,255}. When the drawable is draw, all the pixels are multiplied by this color (white as no effect). Alpha channel and drawable opacity are multiplied together.
color
(table): The color multiplier, as an array of RGBA values.Starts a fade-in effect on this object.
You can specify a callback function to be executed when the fade-in effect finishes.
If the drawable object is a sprite attached to a map entity during a game, the fade-in effect gets the lifetime of that entity. The behavior is probably what you expect: the fade-in effect gets suspended when the entity gets suspended, and it gets canceled (that is, the callback is never executed) when the map entity is destroyed.
delay
(number, optional): Delay in milliseconds between two frames of the fade-in animation (default 20
).callback
(function, optional): A function to call when the fade-in effect finishes.callback
parameter with care. In these situations, using a timer for your callback is easier because timers have an explicit lifetime.Starts a fade-out effect on this object.
You can specify a callback function to be executed when the fade-out effect finishes.
If the drawable object is a sprite attached to a map entity during a game, the fade-out effect gets the lifetime of that entity. The behavior is probably what you expect: the fade-out effect gets suspended when the entity gets suspended, and it gets canceled (that is, the callback is never executed) when the map entity is destroyed.
delay
(number, optional): Delay in milliseconds between two frames of the fade-out animation (default 20
).callback
(function, optional): A function to call when the fade-out effect finishes.callback
parameter with care. In these situations, using a timer for your callback is easier because timers have an explicit lifetime.Returns the offset added where this drawable object is drawn.
This value is initially 0,0
. It is added to whatever coordinates the object is drawn at.
They can be modified by a movement or by drawable:set_xy().
Sets the offset added where this drawable object is drawn.
This value is initially 0,0
. It is added to whatever coordinates the object is drawn at.
x
(number): X offset to set.y
(number): Y offset to set.Returns the current movement of this drawable object.
nil
if the drawable object is not moving.Stops the current movement of this drawable object if any.