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 Jerczu

I am using it for projectiles. Once they reach edge of the screen there is no need for them to be calculated so i use this in projectile entity update function.

update:function(){
		this.parent();
		var pp = this.pos.x - ig.game.screen.x;
        if( pp > ig.system.width || pp<0){
			this.kill();
			//console.log("killed")
		}
		}

1 decade ago by Kxen

Thanks a lot. Exactly what I needed actually. :)

1 decade ago by Jerczu

Glad to be of help - I was searching for it on the forum and no one posted a snippet so when I figured it out I thought I'm ought to share it :)

1 decade ago by gxxaxx

When I have a camera view in a game, it seems like
ig.system.width is the width of the portion of the map that is visible in the camera portal -- not necessarily the width of the full map.

To get around this I use a variable of my own that I set on level load:

this.mapWidth = this.collisionMap.width * this.collisionMap.tilesize;
this.mapHeight = this.collisionMap.height * this.collisionMap.tilesize;

Does the calculations given by Jerczu automatically account for a camera?
Or perhaps, it is for the "no camera" situation?

1 decade ago by hurik

dominic made a nice plugin: http://impactjs.com/forums/help/how-to-find-map-size-in-pixels

when you use it VERY VERY often it could speed up you code :)
Page 1 of 1
« first « previous next › last »