1 decade ago by ShawnSwander
So for the most part coding isn't too hard for me but I'm having trouble spawning something into my game outside of the map editor. In the end I want a mouse click to trigger footprints showing the path to where you clicked. I finished the pathing code but I can't figure out how to make a footprint appear. Any help would be appreciated.
I tried putting the spawn in the init portion and it didn't work either.
ig.module ( 'game.entities.path' ) .requires( 'impact.entity' ) .defines(function(){ var HEX_SIZE = 55; EntityPath = ig.Entity.extend({ size: {x: HEX_SIZE, y: HEX_SIZE}, animSheet: new ig.AnimationSheet( 'media/path.png', HEX_SIZE, HEX_SIZE), zIndex:999, pos: {x: 220, y:220}, init: function( x, y, settings ) { // Add the animations this.addAnim( 'bluenorth', 0.1, [0] ); this.addAnim( 'bluenortheast', 0.1, [1] ); this.addAnim( 'bluenorthwest', 0.1, [1] ); this.addAnim( 'blueeast', 0.1, [2] ); this.addAnim( 'bluewest', 0.1, [2] ); this.addAnim( 'bluesoutheast', 0.1, [3] ); this.addAnim( 'bluesouthwest', 0.1, [3] ); this.addAnim( 'bluesouth', 0.1, [4] ); //flip west facing animations this.anims.bluenorthwest.flip.x = true; this.anims.bluewest.flip.x = true; this.anims.bluesouthwest.flip.x = true; this.currentAnim = this.anims.bluenorth; this.parent( x, y, settings ); }, update: function(){ var myEnt = new EntityPath( 220, 220); var myEnt2 = ig.game.getEntitiesByType( EntityPath )[0]; ig.Game.spawnEntity(EntityPath,220,220); this.parent(); }, }); })
I tried putting the spawn in the init portion and it didn't work either.