1 decade ago by toma
Hi Impact Community,
I am extremely new to the framework and to game development, but I am so excited to dive in.
I have a problem I am trying to solve.
1) I would like to have my player blink after a few seconds of inactivity (e.g. no keyboard input).
2) While in this state, I would like the player to blink every few seconds.
3) Finally, The blinking would stop abruptly once the game resumed (player presses any key)
A real world example would be how Mega Man does it in the old NES games.
A more extreme, but equally relevant example would be how Sonic would start tapping his foot and getting annoyed with you if you put the controller down for an extended period of time. And of course, who could forget when Mario takes a nap in Mario64?
I've been able to get my character to blink every 4 seconds. Of course, he continues to blink even when he is moving. I am stuck on the "only blink when the game is idle" requirement.
Is there a method or property for the game being in an idle state after a certain time interval of inactivity? What about ig.input.isUsingKeyboard? Is there an "any input", or would I have to check all bound inputs?
Thanks in advance for reading this.
init: function(x, y, settings){
this.parent(x, y, settings);
// Add the animations
this.addAnim( 'idle', 1, [0], true );
this.addAnim( 'blink', 0.15, [0,1,0], true );
this.addAnim( 'jump', 1, [2] );
// Set "blink" timer for 4 seconds
this.timer = new ig.Timer();
this.timer.set(4);
},
update: function(){
// blink
if (this.timer.delta() >= 0) {
this.currentAnim = this.anims.blink;
this.anims.blink.rewind();
this.timer.reset();
}
}
I am extremely new to the framework and to game development, but I am so excited to dive in.
I have a problem I am trying to solve.
1) I would like to have my player blink after a few seconds of inactivity (e.g. no keyboard input).
2) While in this state, I would like the player to blink every few seconds.
3) Finally, The blinking would stop abruptly once the game resumed (player presses any key)
A real world example would be how Mega Man does it in the old NES games.
A more extreme, but equally relevant example would be how Sonic would start tapping his foot and getting annoyed with you if you put the controller down for an extended period of time. And of course, who could forget when Mario takes a nap in Mario64?
I've been able to get my character to blink every 4 seconds. Of course, he continues to blink even when he is moving. I am stuck on the "only blink when the game is idle" requirement.
Is there a method or property for the game being in an idle state after a certain time interval of inactivity? What about ig.input.isUsingKeyboard? Is there an "any input", or would I have to check all bound inputs?
Thanks in advance for reading this.
init: function(x, y, settings){
this.parent(x, y, settings);
// Add the animations
this.addAnim( 'idle', 1, [0], true );
this.addAnim( 'blink', 0.15, [0,1,0], true );
this.addAnim( 'jump', 1, [2] );
// Set "blink" timer for 4 seconds
this.timer = new ig.Timer();
this.timer.set(4);
},
update: function(){
// blink
if (this.timer.delta() >= 0) {
this.currentAnim = this.anims.blink;
this.anims.blink.rewind();
this.timer.reset();
}
}