How to perform an action with the condition that the touch

Discussion and feedback on Construct 2

Post » Sun Apr 16, 2017 5:07 pm

q7000 wrote:What I'm doing is the game Pong, at the ends put some walls so that my rackets do not leave the screen, but with the touch if they manage to leave, does not respect their solid state.


Okay cool, I can help. There will need to be an event that prevents the racket from going beyond a grid position,

create another event very similar to the one I helped you with earlier.

If the game board is 300px across and the racket is 20px with a point of origin in the center then 10px will your buffer zone, this is the excess of the racket that will go off screen. so 300 - 10 is 290 so that is how we will find the buffer for the right side of the screen. 0 + 10 is the left side buffer. This helps us make two events:

If touch is > 290 then racket.x = 290

if touch is < 10 then racket.x = 10
B
16
S
7
G
5
Posts: 30
Reputation: 3,777

Post » Mon Apr 17, 2017 12:14 pm

You've had some very good advice on here already, but alternative approach for the first problem would be to create an invisible sprite on each side of the screen abd then use on touch with which sprite is being touched to determine which side of the screen is being pressed. You can also use invisible sprite borders to stop your paddles from going off screen.
B
8
S
3
Posts: 12
Reputation: 626

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: R0J0hound and 3 guests