1 decade ago by wands
hi there,
I'm trying to spawn an entity in the Game. But it's not showing up. What could be the problem.
Main game.js
Tank Entity .js
I'm trying to spawn an entity in the Game. But it's not showing up. What could be the problem.
Main game.js
update: function() {
if (this.init) {
var e = ig.game.spawnEntity('EntityTank1', 200, 200,
{ type: ig.Entity.TYPE.A, checkAgainst: ig.Entity.TYPE.B});//spawn player's char
this.init = false;
e.vel.x = 100;
e.vel.y = 100;
}
ig.log(ig.game.getEntitiesByType('EntityTank1').length);
this.parent();
},
draw: function() {
// Draw all entities and backgroundMaps
this.parent();
}
Tank Entity .js
init: function( x, y, settings ) {
this.addAnim( 'idle',1,[1] );
this.addAnim( 'shield',1,[0] );
this.addAnim( 'hit',1,[2] );
this.zIndex = 10;
this.friction = {x: 800, y: 800};
this.isStun = false;
this.parent( x, y, settings );
},
update: function() {
this.parent();
}
