141 lines
6.2 KiB
HTML
141 lines
6.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
|
|
<html>
|
|
<head>
|
|
<title>Sprites and Images</title>
|
|
<link href="style.css" rel="stylesheet" type="text/css">
|
|
</head>
|
|
<body background="images/back.gif">
|
|
<!--START-->
|
|
|
|
<h3>Sprites and images</h3>
|
|
|
|
Each object has a sprite associated with it. This is either a single image or it consists
|
|
of multiple images. For each instance of the object the program draws the corresponding
|
|
image on the screen, with its origin (as defined in the sprite properties) at the position
|
|
(x,y) of the instance. When there are multiple images, it cycles through the images to get
|
|
an animation effect. There are a number of variables that affect the way the image is
|
|
drawn. These can be used to change the effects. Each instance has the following variables:
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>visible</b></tt>
|
|
If visible is true (1) the image is drawn, otherwise it is not
|
|
drawn. Invisible instances are still active and create collision events; only you don't
|
|
see them. Setting the visibility to false is useful for e.g. controller objects (make them
|
|
non-solid to avoid collision events) or hidden switches.<br>
|
|
<tt><b>sprite_index</b></tt>
|
|
This is the index of the current sprite for the instance.
|
|
You can change it to give the instance a different sprite. As value you can use the names
|
|
of the different sprites you defined. Changing the sprite does not change the index of the
|
|
currently visible subimage.<br>
|
|
<tt><b>sprite_width*</b></tt>
|
|
Indicates the width of the sprite. This value cannot be
|
|
changed but you might want to use it.<br>
|
|
<tt><b>sprite_height*</b></tt>
|
|
Indicates the height of the sprite. This value cannot be
|
|
changed but you might want to use it.<br>
|
|
<tt><b>sprite_xoffset*</b></tt>
|
|
Indicates the horizontal offset of the sprite as defined
|
|
in the sprite properties. This value cannot be changed but you might want to use it.<br>
|
|
<tt><b>sprite_yoffset*</b></tt>
|
|
Indicates the vertical offset of the sprite as defined
|
|
in the sprite properties. This value cannot be changed but you might want to use it.<br>
|
|
<tt><b>image_number*</b></tt>
|
|
The number of subimages for the current sprite for the
|
|
instance (cannot be changed).<br>
|
|
<tt><b>image_index</b></tt>
|
|
When the image has multiple subimages the program cycles
|
|
through them. This variable indicates the currently drawn subimage (they are numbered
|
|
starting from 0). You can change the current image by changing this variable. The program
|
|
will continue cycling, starting at this new index. (The value can have a fractional part.
|
|
In this case it is always rounded down to obtain the subimage that is drawn.)<br>
|
|
<tt><b>image_speed</b></tt>
|
|
The speed with which we cycle through the subimages. A value of 1 indicates that each step we
|
|
get the next image. Smaller values will switch subimages slower, drawing each subimage multiple
|
|
times. Larger values will skip subimages to make the motion faster. Sometimes you want a
|
|
particular subimage to be visible and don't want the program to cycle through all of them.
|
|
This can be achieved by setting the speed to 0 and choosing the correct subimage. For example,
|
|
assume you have an object that can rotate and you create a sprite that has subimages for a
|
|
number of orientations (counter-clockwise). Then, in the step event of the object you can set
|
|
<blockquote>
|
|
<pre>
|
|
{
|
|
image_index = direction * image_number/360;
|
|
image_speed = 0;
|
|
}
|
|
</pre>
|
|
</blockquote>
|
|
<tt><b>depth</b></tt>
|
|
Normally images are drawn in the order in which the instances are
|
|
created. You can change this by setting the image depth. The default value is 0, unless
|
|
you set it to a different value in the object properties. The higher the value the further
|
|
the instance is away. (You can also use negative values.) Instances with higher depth will
|
|
lie behind instances with a lower depth. Setting the depth will guarantee that the
|
|
instances are drawn in the order you want (e.g. the plane in front of the cloud).
|
|
Background instances should have a high (positive) depth, and foreground instances should
|
|
have a low (negative) depth.<br>
|
|
<tt><b>image_xscale</b></tt>
|
|
A scale factor to make larger or smaller images. A value of 1 indicates the normal size.
|
|
You must separately set the horizontal xscale and vertical yscale. Changing the scale
|
|
also changes the values for the image width and height and influences collision events
|
|
as you might expect. Changing the scale can be used to get a 3-D effect. You can use
|
|
a value of -1 to mirror the sprite horizontally.<br>
|
|
<tt><b>image_yscale</b></tt>
|
|
The vertical yscale. 1 is no scaling. You can use a value of -1
|
|
to flip the sprite vertically.<br>
|
|
<tt><b>image_angle</b></tt>
|
|
The angle with which the sprite is rotated. You specify this in degrees,
|
|
counterclockwise. A value of 0 indicates no rotation.
|
|
<b><i>This variable can only be set in the Pro Edition!</i></b><br>
|
|
<tt><b>image_alpha</b></tt>
|
|
Transparency (alpha) value to use when drawing the image.
|
|
A value of 1 is the normal opaque setting; a value of 0 is completely transparent.<br>
|
|
<tt><b>image_blend</b></tt>
|
|
Blending color used when drawing the sprite. A value of c_white is the default.
|
|
When you specify a different value the image is blended with this color. This
|
|
can be used to colorize the sprite on the fly.
|
|
<b><i>This variable can only be set in the Pro Edition!</i></b><br>
|
|
<tt><b>bbox_left*</b></tt>
|
|
Left side of the bounding box of the instance in the room, as defined by its image (taking scaling into account).<br>
|
|
<tt><b>bbox_right*</b></tt>
|
|
Right side of the bounding box of the instance in the room.<br>
|
|
<tt><b>bbox_top*</b></tt>
|
|
Top side of the bounding box of the instance in the room.<br>
|
|
<tt><b>bbox_bottom*</b></tt>
|
|
Bottom side of the bounding box of the instance in the room.<br>
|
|
</blockquote>
|
|
|
|
<p>
|
|
|
|
<!--END-->
|
|
</body>
|
|
</html>
|
|
|
|
<!-- KEYWORDS
|
|
sprite settings
|
|
image index
|
|
image speed
|
|
bounding box
|
|
|
|
visible
|
|
sprite_index
|
|
sprite_width
|
|
sprite_height
|
|
sprite_xoffset
|
|
sprite_yoffset
|
|
image_number
|
|
image_index
|
|
image_speed
|
|
depth
|
|
image_xscale
|
|
image_yscale
|
|
image_angle
|
|
image_alpha
|
|
image_blend
|
|
bbox_left
|
|
bbox_right
|
|
bbox_top
|
|
bbox_bottom
|
|
|
|
--> |