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 Eddie

So I'm working on a game right now and I'm coding my jump function and I want it to work in a specific manner where I need to register an onKeyUp event, that is, the opposite of pressed. Pressed is basically an onKeyDown event, but what I need, which is really, REALLY odd that Impact doesn't have is an onKeyUp event. Anyone have any idea how to do this?

FYI, !pressed doesn't work because this also calls the method EVERYTIME that specific key isn't being held down. That's not what I need, what I need is a one time, onKeyUp event.

Halpz? D:

1 decade ago by dominic

I will add this to the next version. Till then, use this plugin.

Put the following code in lib/plugins/input-released.js (create the plugins/ folder if you don&039;t have it). Require the #plugins.input-released module in your code and use ig.input.released('jump') to check for key release.

ig.module(
	'plugins.input-released'
)
.requires(
	'impact.input'
)
.defines(function(){
	
ig.Input.inject({
	released: function( action ) {
		return (this.delayedKeyup.indexOf(action) != -1);
	}
});

});

1 decade ago by Vertig0

I'm not sure.. but i do this with

if(ig.input.state('crouch')){
   this.crouched = true;
   //statement
}
if(!ig.input.state('crouch') && this.crouched){
this.crouched = false; // or !this.crouched:
//statement here
}


where crouch is the name of the action.
Page 1 of 1
« first « previous next › last »