1 decade ago by ShawnSwander
So based on the data from my map when you right click I want to show the background tile the player clicked on blown up. The scaling script works fine I can't assign a picture without a huge switch statement though. is there a shorter way?
I don't know how to assign an animation from settings or with a varriable name in the assignment.
Here's my attempt
my init (shortened)
I don't know how to assign an animation from settings or with a varriable name in the assignment.
Here's my attempt
if( ig.input.state('rightclick')){ tiles = ig.game.getMapByName('hexes'); tilex = parseInt(ig.input.mouse.x / HEX_SIZE); tiley = parseInt(ig.input.mouse.y / HEX_SIZE); char='abcdefghijklmnopqrstuvwxyz'[tiles.data[tilex][tiley]] settings = "{this.currentAnim = this.anims."+char+";}"; this.messagebox = settings; ig.game.spawnEntity(EntityHexzoom, this.pos.x-165,this.pos.y-165,settings); var hexzoom = ig.game.getEntitiesByType( EntityHexzoom ); //hexzoom.currentAnim = "hexzoom.anims."+char; }
my init (shortened)
init: function( x, y, settings ) { // Add the animations this.addAnim( 'a', 0.1, [0] ); this.addAnim( 'b', 0.1, [1] ); this.addAnim( 'c', 0.1, [2] ); this.addAnim( 'd', 0.1, [3] ); this.addAnim( 'e', 0.1, [4] ); ... this.currentAnim = this.anims.a; this.parent( x, y, settings ); },