How do I create flick to shoot event?

Get help using Construct 2

Post » Sun Jan 29, 2017 7:42 pm

Hi,

How do I create a flick action that shoots a bullet in the direction of the (finger) flick?

My attempts so far haven't worked and there's no "on flick" or "on swipe" action.

Appreciate any help.

Thanks
B
7
S
1
Posts: 41
Reputation: 572

Post » Sun Jan 29, 2017 8:00 pm

The concept is here - https://www.scirra.com/tutorials/560/sw ... th-inertia. If you understand the concepts in the tutorial, it should be simple to apply to a projectile.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,695
Reputation: 64,438

Post » Sun Jan 29, 2017 10:13 pm

Thanks for linking that. Had a look and what he's doing there is completely different from what I attempted.
And I'm none the wiser :(
B
7
S
1
Posts: 41
Reputation: 572

Post » Sun Jan 29, 2017 10:26 pm

Basically, the key is keeping track of the "previous" position and comparing it to the "current" position. In the tutorial, the object being flicked is the "TouchFollowMe" object, which in your case would be your projectile (and your sprite would not be invisible). You also don't need the scrolling part, so you wouldn't be using the Scroll To behavior. You may or may not need the inertia, which can be modified by either changing or removing the lerp() function.

An alternative solution still utilizes the start and end positions of a touch event, but you can simply store the origin coordinates in variables, then use the angle() and distance() expressions with your start and end coordinates to set the properties of your projectile.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,695
Reputation: 64,438


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests