Enemy movement in System.Tick?

Get help using Construct 2

Post » Wed Jan 18, 2012 11:53 pm

I've got some enemy sprites which are moving around by using Platform behavior and simulating the left and right key presses.

However, I realized in the event editor I can use either:
On System.Tick
if(Zombie instance var 'facing' = "left") simulate keypress left
if(Zombie instance var 'facing' = "right") simulate keypress right

or I can simply do a 'Compare instance variable' event:
On (Zombie instance var 'facing' = "left") simulate keypress left
On (Zombie instance var 'facing' = "right") simulate keypress right


Can anyone outline the difference between these from a performance perspective? Which one would you recommend?

Thanks,
-- cacotigon
B
30
S
6
G
8
Posts: 232
Reputation: 6,119

Post » Thu Jan 19, 2012 12:06 am

Not sure if there's a performance hit.
I think it is more about the "elegance" of the event sheet.
Moreover, the "every tick" is a bit redundant, as the "Compare instance variable" is ran every tick anyway in that case (top level event, no other filtering).

I think in the end it's better for readability to not use "every tick" there but I couldn't swear it will have an impact on performances.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Thu Jan 19, 2012 1:35 am

Forget about performance on individual events like that - it's a waste of time. Rendering a sprite will probably take 100 times as long as whatever difference there is, so it basically doesn't matter at all.

I'd recommend using conditions in the object instead of conditions from "system" wherever possible, because events generally work better that way (not because of the performance).
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Thu Jan 19, 2012 2:27 am

okay, thanks, that clears it up for me. I see what you're saying Kyatric, organizing events which pertain to a object through that object's conditions in the event sheet helps with readability/maintainability. Thanks Ashley about trying to use less System events.

Back to coding!
B
30
S
6
G
8
Posts: 232
Reputation: 6,119


Return to How do I....?

Who is online

Users browsing this forum: Megavolt, mnashwan, shinkan, stylie1 and 18 guests