No Revisions Have Been Made To This Page
Can you suggest an edit for this page? Click Here
Sprites are generally the visual representations of objects
within the game you are creating, although they can be used for
many other purposes. A sprite is either a single image, or a set of
images that, when played one after another, looks like a looping
animation. Sprites can be created in many formats, with the
"traditional" sprite being made up of frames of pixel images,
imported into GameMaker: Studio as *.png files.
However you can also import vector sprites that have been
saved in the *.swf format, or skeletal animation
sprites that have been saved out as *.json files with
accompanying *.atlas and *.png files.
Since sprites are an integral part of any game, GameMaker: Studio has a large number of functions that can be used for getting information about specific sprites, or for changing those that are in your game, or even for loading into an application your own sprites from a source image file.
The following functions can be used to get information about a sprite asset. Please note that these functions get the information from the base sprite (ie. the sprite asset) and not from the sprite as it is being used in an instance. For example, you can use instance variable sprite_width to get the width of the sprite that an instance is using and this width will take into account any scaling that may have been applied. However, if you need to know the width of a sprite as it would be normally, with no transforms applied, you would need to use the sprite_get_width() function below. For more information on the sprite instance variables see the section on Instance Properties.
The functions below are all related to changing the sprite asset (resource) itself. This means that the majority of these functions will affect all instances that reference the sprite being changed, it also means that you must take great care to ensure that a sprite exists before referencing it, or to make sure it is not being referenced before changing it.