1 decade ago by congwang0517
I think the event in update() is inefficient. Because user may triger a event infrequent especially in non-action game. But the update() run continuously.
I see the pong example. It also set the catch event function in update()
I think event is a moment thing , when triger a event that change the entity's state instead of using update() to catch a lot of vacant event . Because the update() is used in setInterval may run the function 1000 times by 1 second.So the catch event should not put in update function.
But i don't know how to use the event efficiently.
I see the pong example. It also set the catch event function in update()
update: function() {
if( ig.input.state('up') ) {
this.vel.y = -100;
}
else if( ig.input.state('down') ) {
this.vel.y = 100;
}
else {
this.vel.y = 0
}
this.parent();
}
I think event is a moment thing , when triger a event that change the entity's state instead of using update() to catch a lot of vacant event . Because the update() is used in setInterval may run the function 1000 times by 1 second.So the catch event should not put in update function.
But i don't know how to use the event efficiently.
