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 Doug

Does anyone have a good example of using the mouse to control the movement of an entity? For instance, moving the player paddle with the mouse in the pong demo.

1 decade ago by dominic

You can just call ig.input.initMouse() (or bind one of the mouse buttons). After that, the current mouse position is available at ig.input.mouse.x and ig.input.mouse.y so you can use it to set the entities position in its update function:

update: function() {
	// Center the Paddle on the mouse cursor
	this.pos.y = ig.input.mouse.y - this.size.y/2;
	this.parent();
}

(untested)

1 decade ago by Doug

Alright, thanks. Still figuring how how everything works. Pretty cool so far.

1 decade ago by paulh

why does ig.input.mouse not behave properly on ios?

update: function(){
		 if (ig.input.state('mouseLeft')) {
   	 	ig.game.spawnEntity( FireGib, ig.input.mouse.x,ig.input.mouse.y );
   		
    }

1 decade ago by Arantor

What you do mean by 'not behave properly'? What is it doing that it shouldn't be doing/what isn't it doing that it should be?
Page 1 of 1
« first « previous next › last »