GetAssetPack

Animator Companion for Game Maker

Price
Free
Type
Animations
Creator
Small is Beautiful

A small piece of code you can add to any object to help managing 2d sprite sheet based animations.

Available on

Search by image

Upload a reference to find previews with similar colors, contrast, and detail.

Animator Companion for Game Maker

No preview
Small is Beautiful · itch.ioFree
Animations
License not indexed
  • i Check the terms on the original listing.
Show full terms

A small piece of code you can add to any object to help managing 2d sprite sheet based animations.

View original listing

Description

Companion is a series of objects I've designed to work somewhat like a components: functionalities that you can easily add to any game maker object with a line of code. More components like objects are coming!

Manage Sprite based animations

Show full description...

Animator is a light weight object that you can add to any Game Maker object to help you manage its sprite based animations. It allows you to create and name animation presets, which makes it easy to write and read.

The basic of it fits in the following code snippet :

alt text // CREATE THE ANIMATOR COMPONENT anim = new comp_animator( id ); // CREATE ANIMATION PRESETS anim.create_anim( "walk", 1, 6 ); anim.create_anim( "run_normal", 7, 12 ); anim.create_anim( "run_fast", 7, 12, true, 2 ); anim.create_anim( "combat", 13, 18 ); anim.create_anim( "combo", 20, 30, false ); // SELECT AN ANIMATION TO PLAY anim.play( "walk" );

  • In the Create event of a Game Maker object (will later be referred to the "owner" of the Animator companion), create the companion and assign it to a variable.
  • Use "create_anim( )" to create your presets. It takes several values (some optional):
  • Name of the Animation (String)
  • First Frame (int)
  • Last Frame (int, defaults to First Frame's value)
  • Loop / stops on last frame (bool, defaults to true)
  • Playing speed (the image_speed this animation will use, defaults to 1)
  • Use "play( anim_name )" to start playing a pre-defined animation.

The only thing left to do is to call the Animator's "update( )" function so it actually do it's work! This is typically done in the step event of the Animator's owner.

Cool, eh? But there's more!

Multiple sprite sheet handling

Each animation preset is assigned a sprite. By default this will be the sprite assigned to the object Animator's owner. However you can use "set_default_sprite( sprite_ref )" to define another default sprite. Each preset created after this line will use the new default sprite. This allows you to easily use multiple sprite sheets for the same object.

alt text // CREATE THE ANIMATOR COMPONENT anim = new comp_animator( id ); // CREATE ANIMATION PRESETS anim.set_default_sprite( spritesheet_jack ); anim.create_anim( "walk", 1, 6 ); anim.create_anim( "run_normal", 7, 12 ); anim.create_anim( "run_fast", 7, 12, true, 2 ); anim.create_anim( "combat", 13, 18 ); anim.create_anim( "combo", 20, 30, false ); anim.set_default_sprite( spritesheet_jack_blaster ); anim.create_anim( "walk_blaster", 1, 6 ); anim.create_anim( "run_blaster", 7, 12 ); anim.create_anim( "run_fast_blaster", 7, 12, true, 2 ); anim.create_anim( "combat_blaster", 13, 18 ); anim.create_anim( "combo_blaster", 20, 30, false ); // SELECT AN ANIMATION TO PLAY anim.play( "walk" );

Integration with other companions

Animator is meant to work Ticker, another state machine like companion that allows to write behaviors in an easy to read sequential way. But it can also be used by itself! Either way, it has a few useful functionalities to help you integrate it in your system.

  • reached_last_frame( ) returns true if the animation is at the last frame. Useful to create pauses and chain animations together.
  • get_anim_name( ) returns the name (String) of the currently playing animation.

At less than 150 lines of code, Animator is a very light-weight object. It only does one thing, but it does it well : making a sprite based animation system that is easy to write and read.

Licensing

Animator is free to use in personal and commercial projects. You don't have to credit me. It cannot be resold or used for training AI datasets.

Tags

AnimationGameMaker

Downloads

Name your own price.