1 decade ago by hellagot
Hi,
i am new to impact and trying to make a game without using a level from weltmeister.
So i have defined two entities, the first one only has base functionality, and the second one extends the first one and actually handles the visual stuff:
and
After this i can create a new EntityBoardTileDefense in the map editor and position it on the map, but i do not want to use levels, so i use it in the main.js the following way:
The log says it draws 0 at 50/50, but i do not see anything on the screen.
( well, now lets cross fingers that the post comes out as excpected, i love forums without preview )
Any ideas?
Thank you,
Heiko
i am new to impact and trying to make a game without using a level from weltmeister.
So i have defined two entities, the first one only has base functionality, and the second one extends the first one and actually handles the visual stuff:
ig.module( 'game.entities.board-tile' ) .requires( 'impact.entity' ) .defines(function(){ EntityBoardTile = ig.Entity.extend({ size: {x: 32, y: 32}, init: function( x, y, settings ) { this.parent( x, y, settings ); }, update: function() { this.parent(); } }); });
and
ig.module( 'game.entities.board-tile-defense' ) .requires( 'impact.entity', 'game.entities.board-tile' ) .defines(function(){ EntityBoardTileDefense = EntityBoardTile.extend({ size: {x: 32, y: 32}, animSheet: new ig.AnimationSheet( 'media/tiles/defense.png', 32, 32 ), init: function( x, y, settings ) { this.addAnim( 'idle', 1, [0] ); this.parent( x, y, settings ); }, update: function() { this.parent(); } }); });
After this i can create a new EntityBoardTileDefense in the map editor and position it on the map, but i do not want to use levels, so i use it in the main.js the following way:
defense: null, init: function() { this.defense = this.spawnEntity( EntityBoardTile, 50, 50 ); }, draw: function() { // Draw all entities and backgroundMaps this.parent(); for( var i = 0; i < this.entities.length; i++ ) { ig.log( "drawing "+i+" at "+this.entities[i].pos.x+"/"+this.entities[i].pos.y ); this.entities[i].draw(); } }
The log says it draws 0 at 50/50, but i do not see anything on the screen.
( well, now lets cross fingers that the post comes out as excpected, i love forums without preview )
Any ideas?
Thank you,
Heiko