How do I choose the right 'touch'?

Get help using Construct 2

Post » Tue Dec 23, 2014 7:19 pm

Hi there,

I've got a bit of a problem here which I can't seem to be able to solve on my own...
I'm working on a project/game for a smartphone so I'm using the touch object: if the player touches the screen (is in touch), a bullet is fired.
If a player isn't able to finish a level, a text called 'restart' appears. The player will have to touch this text so the level starts again.
Both 'touches', firing the bullet and restarting the level, work.
The problem is that when the player touches the 'restart' text, a bullet is also fired because of the 'is in touch'...
I hope the issue is clear enough?

I've looked through the tutorials, the manual and the forums, but couldn't find anything...
Can anyone help me solve this issue?

Again many thanks in advance!
Image
B
54
S
24
G
12
Posts: 96
Reputation: 10,316

Post » Tue Dec 23, 2014 7:27 pm

Put the bullet behavior inside a group. Deactivate this group when the restart popup shows up and reactivate it on the start of the layout.

Or you may add a variable, like isActive, add a condition to the bullet touch that the variable equals 1 and set it to 0 when the restart popup is showing and back to one at the start of the layout.

Both approaches will work the same way.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
15
S
3
G
1
Posts: 329
Reputation: 2,012

Post » Tue Dec 23, 2014 7:51 pm

Hi BrunoPalermo,

many thanks for your fast reply!
I tried both methods and got the first one working!
Although I did have to put a 'system wait for 0.1 seconds' at the (new) start of the layout...
Doesn't matter: it works now!

Thanks a whole bunch!
Image
B
54
S
24
G
12
Posts: 96
Reputation: 10,316

Post » Tue Dec 23, 2014 8:35 pm

or just destroy bullets when restart text is touched
B
245
S
39
G
15
Posts: 1,946
Reputation: 40,276

Post » Tue Dec 23, 2014 8:44 pm

All the solutions don't seem to work after all...
The problem is that I also use a 'on any touch end'; I think the problem might be caused by this one...
I'll post my capx, maybe things are more clear then.

Aim of the game is to destroy the yellow blocks by shooting them.
To make things easier, if you click somewhere on the screen a line is drawn from the player to this point so you can see where the bullet will hit for the first time.
This way it's easier to 'calculate' where the ball should hit a wall or a blue block...

I'm really stuck here... :shock:
You do not have the required permissions to view the files attached to this post.
Image
B
54
S
24
G
12
Posts: 96
Reputation: 10,316

Post » Tue Dec 23, 2014 9:09 pm

wait a second!... :D
You do not have the required permissions to view the files attached to this post.
Image
B
64
S
23
G
7
Posts: 1,483
Reputation: 10,827

Post » Wed Dec 24, 2014 5:44 am

Yeah korbaach,

that works!
Although I don't really get the logic behind it....

Thanks a lot!
Image
B
54
S
24
G
12
Posts: 96
Reputation: 10,316

Post » Wed Dec 24, 2014 6:01 am

Rjan wrote: I don't really get the logic behind it....

your actions ..restart layout..spawn bullet..and a few more(set global variable..).. all took place in one tick...
simple delay between action stop spawning bullets.. but your code have more logical errors..
Image
B
64
S
23
G
7
Posts: 1,483
Reputation: 10,827

Post » Wed Dec 24, 2014 6:47 am

Ok, that makes sense...

Well, to be honest, I would be surprised if my code DIDN'T have logical errors in it ;)
Maybe, given the fact that I still have a lot to learn, you would be so kind to point out some errors?
You don't need to give me the right code or whatsoever but if I know what's wrong, I can try to figure it out myself.
So far the game does what I want it to do, but I'm sure there are many things to improve!

Thanks so much again!
Image
B
54
S
24
G
12
Posts: 96
Reputation: 10,316

Post » Wed Dec 24, 2014 7:37 am

Sorry man!
..I did not want to be rude (stupid google translate ;) )
there is no good or bad code.. only effective or not effective ...
,we all still learning...and we will learn all our life... :D ..Merry Christmas and Happy New Year.. :D
Image
B
64
S
23
G
7
Posts: 1,483
Reputation: 10,827

Next

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Allardje, Rudi55 and 1 guest