绘制精灵和图块

Even though you can set up backgrounds in the room editor and you can assign sprites to instances, often this is not flexible enough for the game you are making. For example, if you have an instance that has to draw a menu, you may want to display various button sprites at a time, or if you have a game with scrolling parallax backgrounds you will need to be able to set them through code in a controller instance of some type. In these situations you should be using the following functions which can draw sprite and background assets anywhere in the room with some of the functions also permitting you to manipulate the shape, size, colour and alpha of the sprite to achieve special effects.

You can assign a sprite to an instance and by default GameMaker Studio 2 will draw it with the properties given by the various sprite variables, however if you add anything into the draw event, you are "taking control" and must tell GameMaker Studio 2 exactly what to draw. This means that if you must use the following functions to define exactly what it is the instance is to draw and where about in the room it is to draw it:


If you are using SWF format sprites, then there are also additional options for controlling the anti-aliasing used when drawing (see Importing Non-Bitmap Sprites for more information on these types of sprites). Note that these functions work on a global level and will set the AA on all vector SWF sprites drawn after they have been called.


Apart from those functions listed above, there are also two special functions designed for use with skeletal animations (see Importing Non-Bitmap Sprites for more information on these types of sprites, and the section Skeletal Animations for specific functions related to these types of sprites):


Tiles are drawn automatically based on the data that they contain, the tile set used and the tilemap properties. However you can draw individual tiles or tilemaps using the following functions:


上一页: Drawing
下一页: Drawing Text
© Copyright YoYo Games Ltd. 2018 All Rights Reserved