1 decade ago by inihility
Hello everyone, I'm new to ImpactJS and JavaScript in general so please be easy on me!
I'm trying to spawn entities from another .js file and this is the code I have right now.
options.js
selectscreen.js
At this point the entity seems to have spawned as I am able to get the "entityspawned" message in the console but nothing shows up on screen. Any ideas on what might be going wrong?
I'm trying to spawn entities from another .js file and this is the code I have right now.
options.js
ig.module( 'game.entities.options' ) .requires( 'impact.entity', 'impact.image' ) .defines(function(){ EntityOption1 = ig.Entity.extend({ image: new ig.Image('media/image.png'), size: {x: 146, y: 100}, init: function( x, y, settings ) { this.parent( x, y, settings ); console.log("entityspawned"); }, }); });
selectscreen.js
ig.module( 'game.screens.selectscreen' ) .requires( 'impact.game', 'impact.font', 'impact.image', 'game.entities.options' ) .defines(function(){ ModeSelect = ig.Game.extend({ font: new ig.Font( 'media/04b03.font2.png' ), backgroundImage: new ig.Image('media/game_bg_pc.png'), init: function() { // Initialize your game here; bind keys etc. //ig.game.spawnEntity(EntityOption1, 320, 240); //this.backgroundImage.resize(0.5); }, update: function() { }, draw: function() { // Add your own drawing code here var x = ig.system.width/2, y = ig.system.height/2; this.backgroundImage.draw(x - (this.backgroundImage.width)/2,y - (this.backgroundImage.height)/2); this.font.draw( 'Choose your allegiance', x, y * 1.6, ig.Font.ALIGN.CENTER ); this.list(); }, list: function(){ ig.game.spawnEntity(EntityOption1, 320, 240); } }); });
At this point the entity seems to have spawned as I am able to get the "entityspawned" message in the console but nothing shows up on screen. Any ideas on what might be going wrong?