"Throw" object in tow-down view with Sine behavior

Get help using Construct 2

Post » Wed Sep 11, 2013 6:16 am

CAPX: https://www.sugarsync.com/pf/D6025908_4317202_6900854

The game play is a top-down view. What I'd like to do is create an item (object GrenadeFlash) that, when "thrown" from the player (object CharFinn), it will appear as if it's rising in elevation as you look down. Naturally, as something comes closer to you, it appears to be getting larger. This is where the Sine behavior comes in.

The problem I'm facing, though, as I learn how to use the Sine behavior is how to stop it mid-period. Let's say the object I'm using is 10 pixels wide and I want its size to expand by 10 (to a max of 20) during its run through the Sine behavior. I've noticed, however, that it will shrink to less than 10 pixels before it finishes its cycle.

What I want to do is set it so that when it is launched, it will increase to my desired max size then return to its original size and then be destroyed. I can figure out the movement of the object and destroying it. What I'm not sure about is how to cut it off mid-period.

Any suggestions?
Thanks!Rhindon2013-09-11 06:18:00
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
142
S
24
G
8
Posts: 791
Reputation: 15,148

Post » Wed Sep 11, 2013 8:00 am

I'm not quite sure how it is supposed to work, for I haven't used Sine-behaviour myself.

This workaround seemed to work though:

- adding a timer-behaviour to the grenade.
- add a subevent on spawn to set the timer to half the sine-period
- on timer - destroy grenade.

I added another sine and set it to forward-backward and period to 8
This really gave the idea of throwing and by setting the magnitude you can decide on the distance of the throw.

it's not a very clean workaround, but did get reasonable results.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Sep 11, 2013 8:08 am

The sine behavior is not designed for that. Its destination is to loop indefinitely.

Luckily, doing your own sine-based behavior is one of the easiest things in programming (at least if your ever heard of sin and cos in school and know how to use wikipedia).

Here's a simple example (copy.com link): throw_sine.capx
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Fri Sep 13, 2013 4:14 am

Thanks, guys. I appreciate the feedback. :)
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
142
S
24
G
8
Posts: 791
Reputation: 15,148

Post » Fri Sep 13, 2013 4:19 pm

Dear @tulamide

I can't get your example from copy.com.

I might doing something wrong but I registered in order to download it and if I click on download I get this:

{"result":"error","error_code":"1012","error_string":"Cannot find requested object id "}

If I send it on the copy folder and try to download it from there, it comes as an 22kb zipped file which is empty?!

Can you check on the copy.com link or provide us an other download option to your (very informative I am sure) example?

Thank you,

Elias
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Fri Sep 13, 2013 4:40 pm

Seems, copy.com does have issues. I used it mainly to test exactly that. However, I updated the link here:
throw_sine.capx

I expect it to render invalid soon, so grab it while it's hot^^ Does anybody know if copy.com links have a time window?
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Fri Sep 13, 2013 7:05 pm

This second link did the trick for me!

Man, this is the simple programming?!?

Thank you very much @tulamide !!! Again, once more an excellent example!!!
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, mindragon73 and 22 guests