How do I Swipe over an object and move it

Get help using Construct 2

Post » Thu May 14, 2015 2:49 pm

Hello all,

like a bat with a ball. I tried the "hold gesture over" and the other gesture control but noone of this work.

Many thanks
B
3
Posts: 2
Reputation: 354

Post » Thu May 14, 2015 3:17 pm

you can move the bat by calculating distance of mouse :

a good example is my pool game, basically does the same thing, the code in it, its from the construct 2 template, the angry birds example, you just need to adapt the code from the elastic thing to your needs, basically you need 2 numbers to save X and Y of the touch or mouse,

but for your bat you need to rotate so you just need the mouse x y or touch x y and 1 original position of the bat

and then make the bat object move left or right or rotate by using the position of mouse pressed , so the code will be like this lets say for example that you know the original state position of the bat where you want it to be so lets call that OriginBatAngle and we will use a boolean if you want to make it trigger safer so it wont make buggy moves when you random click screen, so lets call the boolean Swing

then the code will look like this

On start of layout
set OriginBatangle to Batobj.angle

On touch on object bat

Trigger once

set boolean Swing True

Is boolean Swing
Rotate 2 Degrees towards position touch.x touch.y

On touch released
trigger once
set boolean swing false


Is boolean Swing (x inverted)
rotate 2 degrees towards angle OriginBatangle


and that should do it! il make you a quick capx if you want! reply here!
B
78
S
23
G
69
Posts: 1,353
Reputation: 44,005

Post » Thu May 14, 2015 3:27 pm

How can you calculate the collision from the bat and the ball ?

I am making a game where a bear try to catch fish. The player swipe on the mobile and if the bear arms touch the fish, this one fly in che chest.

I need something for the collision.
B
3
Posts: 2
Reputation: 354

Post » Thu May 14, 2015 3:53 pm

the colision system is already there, you can set a condition on the fish, that says,

( arm or bat) if you have it pinned, if not i guess the bear animation has a box boundry autodetected, and the fish will automatically detect it when it hits it on the first edge of that.

On collison with object bear

then you trigger your events for flyng fish in chest!

i can do a capx for you but you have to wait a moment! :) have a few things to do :D


here is a capx from meDOWNLOAD

and here are some demos that might help you (lost and found on internet)
B
78
S
23
G
69
Posts: 1,353
Reputation: 44,005




Return to How do I....?

Who is online

Users browsing this forum: MadSpy and 21 guests