-
Notifications
You must be signed in to change notification settings - Fork 2
Getting Started
The releases page offers a local package for GameMaker Studio 2 that can be installed by dragging the file into the IDE. Only scr_disarm
is strictly required in order for the library to be functional. A test object has been included that demonstrates how the library might be used.
No significant setup is required in order to use Disarm. However, since it is possible for sprites to be loaded externally from a file, it would be wise to call disarm_flush()
periodically, or in the Room End event in order to avoid memory leaks. Note: if you never load sprites from external files, you do not need to do this.
Once you have completed your animation in Spriter, navigate to File > Generate spritesheets for project images
. From here, select the size and packing method of the texture atlases. Next, tick "save spritesheeted project" and select "save as scon (json)," then tick "embed spritesheet info into project file." These settings are required by Disarm and are not optional, see the image below if you are unsure what settings should be selected. Finally, choose a file location to export your animation to and click Ok.
The following example shows how to import a Spriter animation from a file, apply an animation to a mesh, and finally render that mesh to the screen:
Here we load the animation and initialise the mesh the animation will be rendered to.
// load the animation from the included files
arm = disarm_import("wanda.scon");
// initialise the mesh that animations will be rendered to
mesh = disarm_mesh_create();
// keep track of the animation time
aTime = 0;
aSpeed = 0.01;
Make sure to delete the mesh once you are done with it! This is because the mesh dynamically allocates vertex buffers to handle the rendering.
// free the resources associated with the mesh
disarm_mesh_destroy(mesh);
Here we calculate the animation pose and apply it to the mesh.
// update the animation time
aTime += aSpeed;
if (aTime > 1) {
aTime -= 1;
}
// calculate the run animation pose
disarm_animation_begin(arm);
disarm_animation_add(arm, "Run", aTime);
disarm_animation_end(arm);
// apply the pose to the mesh at the current objects X and Y position
disarm_mesh_begin(mesh);
disarm_mesh_add_armature(mesh, arm, x, y);
disarm_mesh_end(mesh);
Here we submit the mesh to be rendered.
// submit the mesh to be drawn
disarm_mesh_submit(mesh);