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
31
S
7
G
8
Posts: 232
Reputation: 6,214

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
262
S
93
G
54
Posts: 7,139
Reputation: 66,547

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
373
S
218
G
83
Posts: 23,433
Reputation: 185,806

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
31
S
7
G
8
Posts: 232
Reputation: 6,214


Return to How do I....?

Who is online

Users browsing this forum: Blacksmith, Yahoo [Bot] and 10 guests