banner



Game Maker Studio 2 How To Drop A Sprite Sheet In As An Animation?

Introduction

In this tutorial nosotros are going to look at the GameMaker Studio 2 Sprite Editor. The sprite editor is where y'all define the different sprite resource that your game volition use, which ways assigning (or creating) an epitome for them and setting upward certain basic properties.

You can too watch the following video on the Sprite Editor:

The sprite editor window looks like this:

The Sprite Editor

Sprites are used for near everything that will be drawn in your game, only can also form the basis for collisions (in full general) betwixt instances. In this tutorial we will explicate how to add an image, set up these properties and ensure that information technology has an advisable collision mask. Showtime you need to add a sprite to your project, which is done by correct clicking on the Sprite resource folder and selecting Create.

Adding Frames

Sprites are the basically the graphics for your whole game. About everything that you depict within the game, with the exception of text and 3D models, will be fatigued using sprites, and sprites as well play a very important office in collisions too. A bitmap sprite (*.bmp, *.jpg, *.png, *.gif) can be a single image, a composite image (for making tile sets), a grouping of images or a strip of images, as shown beneath:

Image Formats

Yous tin can also import Skeletal Animation sprites (made with the program Spine and Vector sprites (*.swf). These are treated slightly differently within GameMaker Studio 2 and so please bank check the manual (press ) every bit this tutorial is going to concentrate on bitmap sprites.

Adding an prototype tin can be done either by clicking Import and and then selecting either a unmarried paradigm file or multiple single image files. If you select multiple files, they will be added as separate frames (likewise called sub-images) of the sprite and they should all be the aforementioned size for all-time results. If you wish to import a sprite strip or create a new epitome (or prepare of image frames) then y'all need to click on the Edit Epitome button to open up the Paradigm Editor. We won't go into any details about the image editor as nosotros have a tutorial on how to utilize it and all the tools are explained in the manual, but nosotros will briefly explain how to add a sprite strip to create multiple sub-images - simply open up the Image Editor, goto the Image bill of fare and select Import From Strip, then select your image file to import. Y'all will be shown options for how to carve up the sprite into frames before information technology is imported.

Notation: You lot tin can add a strip sprite directly from the Import button if the sprite name has been suffixed with "_stripXX". GameMaker Studio 2 will automatically split the image into the number of frames given - for case a strip paradigm with 12 frames could exist named "player_strip12.png" and on import the strip will exist automatically split up into the required 12 frames.

Once you lot've imported your sprite, you can name it - utilize regular characters, numbers and the underscore "_", and many people prefix their resources to make them easier to identify, like "spr_Player" or "sTree" - and so set the Texture Settings. All sprites are stored on texture pages (as well known as texture atlases), so if you lot have twenty sprites in your game, they will all be placed on a single texture folio. This is a standard optimisation for storing and using graphics, but information technology does mean that you lot need to fix a couple of things up.

Basically, sprites become onto a texture page with a sure number of pixels as padding around the edge. This is done so that when scaling up or down to non-integer values the image uses the correct pixels, so an image that is to be tiled will take the edges (horizontal or vertical) added to by the edges from the opposite side, while if no tiling is selected the sprite will exist clamped and the edges pixels will be repeated (smeared). The following paradigm illustrates this:

Texture Values

The selection Separate Texture Folio volition add the sprite to a single texture page merely for it (in general you lot'd utilise this only with 3D or shaders), and yous can also choose a specific Texture Group to have it assigned to (meet the manual for more details on these aspects of the sprite editor).

The concluding two texture options tin more often than not be left unchecked, every bit they chronicle to certain visual artifacts that can show up when a sprite is added to a texture folio. By selecting Pre-multiply Alpha yous will exist telling GameMaker Studio two to "fix" the semi-transparent pixels of your sprite by pre-multiplying it with the matte colour of the alpha aqueduct before placing information technology on the texture page - this should but exist enabled if y'all take issues when placing sprites with feathered or emmet-aliasing edges into your game, and isn't guaranteed to set up these issues (you may need to re-edit them in the sprite editor or another image processing software). As for Edge Filtering, this option is specifically for when you take linear interpolation enabled for your game and you are seeing "halos" of colour around your sprites. This is caused by the hardware interpolating from multiple source texels on the texture page all at one time, and can be especially obvious when yous scale games up in resolution. Enabling this will filter the border pixels to take on the colour of the nearest total alpha sprite pixel and so alloy the interpolated pixels without the halo that was present previously.

Animated Sprites

If you lot've added an animated sprite, ie: one with a number of prototype frames, then you will see each frame of the animation shown in the Sprite editor, and y'all can click on whatsoever of them to select it to be shown in the master preview window. If yous press while on a selected frame you can remove it from the sprite, and you can also select multiple frames pressing + on the frames you want to select together.

Animation Frames

Higher up the preview and frames window you have buttons to Play the blitheness, loop or ping-pong the blitheness when previewing. Abreast these controls you can prepare the animation speed likewise. This value is based on the game frames (a game frame is the time it takes to practice 1 total game "loop"), so if yous have, for example, a game fps (frames per second) of 60, and set the animation speed to x, the blitheness will loop 6 times every second. Setting this value here will impact how the animation will expect in the game, and is non just for preview purposes.

Animation Preview

It's worth noting that you can set the blitheness to run either using frames per 2d, or frames per game frame, so choose carefully which one you use equally fifteen frames per second is not the same equally 15 frames per game frame!

Sprite Origin

In the middle of the editor you have a bar for defining the sprite origin and the standoff mask (we'll cover the collision mask in next folio of the tutorial):

Sprite Origin Bar

The origin of the sprite is the betoken on the sprite that corresponds to its position inside the room, ie: when you create an instance at a particular (x/y) position, the origin of the sprite is placed there. By default it is the summit left corner of the sprite simply it is often more convenient to use the center it, or you may desire some other signal on the sprite. To change it, you can set the origin manually by clicking in the sprite preview prototype which volition movement the origin cross (indicated in the image above) to the betoken you clicked, or you tin input dissimilar values for ten and y in the corresponding boxes. For fixed placement (and to make things easier) there is a drop down menu with a number of preset positions that yous tin can choose from:

Origin Preset Values

Note that you can even gear up an origin outside the area of sprite by using negative numbers (for left and up) or positive numbers larger than the sprite width and height (for right and downwards), which tin be very useful when dealing with objects that need to be drawn with composite sprites.

Collision Mask

The final thing to talk virtually in this tutorial is the ability to prepare the collision mask for a sprite. The collision mask is the area that GameMaker Studio ii uses to calculate when two instances with sprites assigned are in standoff (or not) and trigger a Collision Effect. Expanding the collision mask menu presents you with a number of options and gives a graphical representation of the current standoff mask on the preview window:

Editing The Collision Mask

The mask will, by default, encompass the whole image surface area, simply you can click any of the mask "handles" (marked in the image to a higher place) and so drag to resize the mask. Manually setting the mask will ignore the alpha tolerance value, simply if you set this then it will automatically calculate the mask area based on the alpha value of the pixels that make upward the sprite and ignore whatever manual values you have set. You tin also switch on/off the preview using the command in the heart bar of the sprite editor.

NOTE: The area covered by the collision mask is commonly chosen the bounding box and there are special variables for getting this value from sprites while your game is running, useful for doing your ain custom collisions.

You are not limited to a rectangular standoff mask and tin choose from any of the following equally well:

Different Collision Masks

Annihilation except the default rectangular collision mask will exist slower to procedure than the rectangle, but by far the slowest to process are those marked as precise. These are per-pixel collisions and so crave much more processing to resolve. Likewise note that the normal Precise collision will exist based off of a mask created from the superimposition of all sub-images within the sprite to create a unmarried mask, while the choice Precise Per Frame will create a unique mask for every single frame of the animation.

Summary

That brings us to the end of the Sprite Editor tutorial. Equally e'er, you tin can find more in-depth details virtually everything discussed here from the manual (printing ), simply you should at present take no issues creating sprites ready for employ in your game. But remember: don't forget to set the origin to the sprites you make appropriate to your projection and likewise don't forget to check the standoff mask for the sprites you make, as the default values are non e'er the all-time.

Source: https://gamemaker.io/en/tutorials/sprite-editor

Posted by: flemingyourejough.blogspot.com

0 Response to "Game Maker Studio 2 How To Drop A Sprite Sheet In As An Animation?"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel