Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

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

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();
              
}			
		

1 decade ago by dominic

Do you see any error messages in your browser's console?

Check the name of the Entity: You&039;re spawning #EntityTank1 but the name of the file is Tank Entity.js.

Otherwise, the code you posted looks alright. The error is probably in the code you didn't post :) Maybe you mistyped the file name of your sprite sheet?

1 decade ago by wands

i found out the problem. My screen.x was set to another location, that's why it's not showing up. Thanks for the reply anyway Dom.
Page 1 of 1
« first « previous next › last »