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 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()
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.

1 decade ago by Arantor

It really shouldn't be changed. If it's done any less frequently than it is right now, you could receive input a frame or two (or more) behind the output that prompted the frame.

Imagine a platform game like Biolab Disaster where keyboard response was 1 frame behind. You could travel 2-3 pixels between frames in some circumstances, which is enough to be the difference between standing and falling off a ledge.

1 decade ago by dominic

Technically you are correct, but the performance hit for the update() is really minuscule. Ask the Debug Panel or your Browser's profiler if you don't trust me :)

Evented input is great for user interfaces - such as websites - but somewhat awkward to work with for real-time games. It was a conscious decision that Impact&039;s API doesn't use any events or callbacks at all. Knowing that all #update() functions are called once per frame makes your project much more easy to reason about.

1 decade ago by congwang0517

Thanks, the reason is I just think game as website. So i was confused why impactjs has not any function like jquery's event and callback. The reason is also jquery hasn't develop a html5 game engine I guess.
Yet I create any callback function in impact entity class as to transfer data to server-side in my Social Game.
Page 1 of 1
« first « previous next › last »