Should I use "on every tick" or pin for sprite skins?

Just started using Construct 2? Post your questions here

Post » Thu Dec 08, 2016 9:28 pm

In the excellent jungle platform tutorial, we are taught to attach an invisible placeholder box to the player skin. As part of that tutorial, we learn how to use the "on every tick" event to attach the skin to the placeholder box.

In other tutorials and examples, people use the pin behavior to attach a sprite skin to a placeholder box. This also seems to work just fine.

Is one of these approaches recommended over the other approach? In a way, the pin behavior seems slightly more elegant because you just need to do it once rather than having the command executed in your event sheet on every tick. But I guess the pin behavior is probably doing the same thing underneath the hood?

Thanks for any advice! :D
B
9
Posts: 16
Reputation: 363

Post » Thu Dec 08, 2016 10:10 pm

i tend not to use much behaviors, in this case i personally would do Every tick -> Set position of PlayerSkin to both HitBox.X and .Y
of course, if that's what you want to do (it's what i could understand)
B
7
S
2
Posts: 16
Reputation: 555

Post » Thu Dec 08, 2016 10:39 pm

What if you were doing this with a collection of enemies? For example, imagine that I had 12 fox enemies with their own skins. Would this still seem appropriate?

I guess I am wondering if there is any advantage of doing it one way?
B
9
Posts: 16
Reputation: 363

Post » Thu Dec 08, 2016 10:49 pm

adelwich wrote:What if you were doing this with a collection of enemies? For example, imagine that I had 12 fox enemies with their own skins. Would this still seem appropriate?

I guess I am wondering if there is any advantage of doing it one way?


well there are tons of different cases with different solutions, for the player i just use the every tick
B
7
S
2
Posts: 16
Reputation: 555

Post » Fri Dec 09, 2016 12:17 am

Behaviours are there to make your life easier, and typically will run more efficiently since they are native JavaScript, as opposed to the engine having to do the overhead of decoding events. In this particular case there isn't going to be a huge difference. Do what's easier for you.
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Fri Dec 09, 2016 12:39 am

Thanks, everyone. I appreciate the advice, and it makes sense that native JS will run faster than it would if the engine is required to do the overhead.
B
9
Posts: 16
Reputation: 363

Post » Tue Dec 13, 2016 1:01 pm

just keep in mind when using every tick make sure that you arent using too many at once. Cause ive seen it rubberband lag me to no end when debuggin even in devoloper mode.
B
51
S
24
G
6
Posts: 391
Reputation: 7,820

Post » Tue Dec 13, 2016 1:30 pm

Pin always when you need something pinned on a moving object, else, pin and unpin. Try avoid check too much events at once in everytick and if possible use "triggers" and "else" where possible to make your events light, running only the necessary.

You'll see it and understand better while you mature your usage of C2.
Image
B
104
S
23
G
17
Posts: 1,350
Reputation: 22,028

Post » Tue Dec 13, 2016 3:07 pm

Thanks, Gabriel. This makes sense. It does seem logical that pinning and triggered events would be more efficient than using once every tick. I wonder if someone should update the "jungle platform tutorial" to emphasize the use of pinning rather than on-click events. Hmm... I'll just add a comment to the bottom of that tutorial.
B
9
Posts: 16
Reputation: 363


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests