1 decade ago by paulh
Hi all
Thanks for your continued help on the board id be completely stuck with you!
Id like to spawn an entity from a fixed position on the screen and not have it scroll with the scrolling map. Im using a fixed velocity on the player to scroll the map.
Im using the laser class from : http://impactjs.com/forums/help/drawing-a-laser-beam-effect
Currently i have the laser spawing but it scrolls of the map and will keep spawning (on button press) off the screen.
How would i make it so the laser is drawn from a fixed position on the screen to the mouse co-ordinates and the effect is "static" (not scrolling) on the screen.
##main.js
if( ig.input.pressed('shoot') ) {
ig.game.spawnEntity( EntityLaser, 200, 200 );
}
##
Also i noticed that my entities arent being killed when they exit on the left side of the screen, how do i kill them when they're off screen?
Many thanks
Thanks for your continued help on the board id be completely stuck with you!
Id like to spawn an entity from a fixed position on the screen and not have it scroll with the scrolling map. Im using a fixed velocity on the player to scroll the map.
Im using the laser class from : http://impactjs.com/forums/help/drawing-a-laser-beam-effect
Currently i have the laser spawing but it scrolls of the map and will keep spawning (on button press) off the screen.
How would i make it so the laser is drawn from a fixed position on the screen to the mouse co-ordinates and the effect is "static" (not scrolling) on the screen.
ig.module("game.entities.laser").requires("impact.entity").defines(function() { EntityLaser = ig.Entity.extend({ start: {}, target: {}, init: function(x, y, settings) { this.parent(x,y,settings); this.target.x = 300; this.target.y = 500; this.timer = new ig.Timer(0.25); }, update: function() { if (this.timer.delta() >= 0) { this.kill(); } this.parent(); }, draw: function() { var startX = ig.system.getDrawPos(this.pos.x - ig.game.screen.x); var startY = ig.system.getDrawPos(this.pos.y - ig.game.screen.y); var endX = ig.system.getDrawPos(this.target.x-ig.game.screen.x); var endY = ig.system.getDrawPos(this.target.y-ig.game.screen.y); ig.system.context.strokeStyle = "yellow"; ig.system.context.lineWidth = 20; ig.system.context.beginPath(); ig.system.context.moveTo(startX,startY); ig.system.context.lineTo(endX,endY); ig.system.context.stroke(); ig.system.context.closePath(); } }); });
##main.js
if( ig.input.pressed('shoot') ) {
ig.game.spawnEntity( EntityLaser, 200, 200 );
}
##
Also i noticed that my entities arent being killed when they exit on the left side of the screen, how do i kill them when they're off screen?
Many thanks