Class: Pixiurge::Display::TileAnimatedSprite
- Inherits:
-
Pixiurge::Displayable
- Object
- Pixiurge::Displayable
- Pixiurge::Display::TileAnimatedSprite
- Defined in:
- lib/pixiurge/displayable/tile_animated_sprite.rb
Overview
TileAnimatedSprites are good for playing tile-based animations from one or more tile sheeets.
Instance Attribute Summary
Attributes inherited from Pixiurge::Displayable
#block_height, #block_width, #displayable_type, #location_displayable, #location_name, #name, #position, #x, #y
Instance Method Summary collapse
-
#initialize(parameters, name:, engine_connector:) ⇒ TileAnimatedSprite
constructor
Constructor - create the sprite.
-
#messages_to_show_player(player) ⇒ Array
Show this Displayable to a player.
Methods inherited from Pixiurge::Displayable
#destroy_for_player, #move_for_player, #show_to_player
Constructor Details
#initialize(parameters, name:, engine_connector:) ⇒ TileAnimatedSprite
Constructor - create the sprite
In addition to normal Pixiurge Displayable parameters, a TileAnimatedSprite takes a params hash in a very specific format.
For tilesets, the url property is where to load the tileset from, usually on the game's asset server(s). The tile_width, tile_height, spacing and margin define the size and location of the frames within a tileset. The first_frame_id defaults to 1 for the first tileset and gives the frame ID (number) for the very first frame number of that tileset. For later tilesets, the frame numbering begins with the next unused frame ID - so a tileset with room for 24 images followed by a tileset with room for 6 images will have frame IDs between 1 and 30 unless one of them sets first_frame_id.
Properties for animations: frames, after (opt). Frames is an array. each element may be an integer, in which case it's a frame ID
The default value for "after" is "stop". Special values for "after" are "loop" and "stop". It can also be set to the name of another animation in the same TileAnimatedSprite.
The "tileset" property of an animation gives the default tileset for any frame that doesn't specify. The default value is the first tileset.
The "frames" property of an animation is an array of frame specifications. A frame can be a number, which is a frame number as defined by the tilesets. A frame can also be a structure with a duration and frame_id. Or it can be a structure with a duration, an x and y coordinate for the upper left corner, a width and height, and a tileset name.
81 82 83 84 85 86 |
# File 'lib/pixiurge/displayable/tile_animated_sprite.rb', line 81 def initialize parameters, name:, engine_connector: @parameters = parameters @displayable_type = "tile_animated_sprite" check_parameters super(name: name, engine_connector: engine_connector) end |
Instance Method Details
#messages_to_show_player(player) ⇒ Array
Show this Displayable to a player.
93 94 95 96 97 |
# File 'lib/pixiurge/displayable/tile_animated_sprite.rb', line 93 def (player) = super [0].merge!({ "params" => @parameters }) end |