Destroy on Touch

Get help using Construct 2

Post » Wed Mar 21, 2012 3:01 am

Hi
I'm making a game were you basically mine for some gold. Im fairy new to C2 and I need to destroy a object with out destroying all of them.
B
12
S
1
Posts: 18
Reputation: 824

Post » Wed Mar 21, 2012 3:30 am

Then you have to understand how events work to pick only the instance you want to disappear.
As you are mining something, I guess you could pick only the bit of ground that is in touch with the digging tool.

Or maybe are you using an instance variable and in that case just need to pick the instances by testing which one has a specific value for this variable.

Hard to tell with your short description.

At worst, post your capx, it will be easier to provide help.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Wed Mar 21, 2012 3:46 am

I am in need of a way to destroy one piece of stone with out destroying all of them. Right now all I have in my events sheet is
Mouse~Double Left Click= Destroy Stone
I'm not sure if there is a way to destroy just the single stone that the mouse has just double clicked.
B
12
S
1
Posts: 18
Reputation: 824

Post » Wed Mar 21, 2012 3:54 am

Assuming your stones are seperate sprites, the condition and action you just described should only destroy the stone that is clicked.

If you want to destroy the stone after touching it a certain number of times (eg Terraria with a weak pickaxe), you can add a local variable to each type of stone. For example, each "normal stone" could be worth 5.

Then you create condition:

Mouse click on stone = subtract 1 from local variable.
Local variable equal to 0 = destroy object

Again, as long as your stones are separate instances of the object, only the instance that is being clicked will be affected.
B
6
Posts: 22
Reputation: 751

Post » Wed Mar 21, 2012 4:05 am

Ok Thanks! I didn't have all the stones as different sprites and now I'm off to go change that.
B
12
S
1
Posts: 18
Reputation: 824

Post » Wed Mar 21, 2012 4:18 am

You don't need different sprites, but instances.

Also, instead of the "Mouse:Double click" condition, you should rather use "Mouse:On object clicked" and set it as "Double clicked" and your "Stone" object.
This will pick ONLY the instance you've just double clicked.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Wed Mar 21, 2012 10:26 am

@Kyatric: I recently found out that its funnier to avoid the 'Mouse' object completly - if possible.
=> using the 'Touch' object => Property: 'Use mouse input' - Yes
=> having both - touch and mouse-click (fallback when the browser doesn't support touch)
Link to the tutorial Touch
Pro: Making the whole project browser independent - eg - for the i-devices. Afaik i-devices don't support mouseclick-conditions on sprites,...
Cons: Mouse over an object and Mousescolling are the only two conditions that are not given by the Touchobject - I think.

Anything speaking against that or I haven't seen? Joe72012-03-21 10:58:34
B
14
S
6
G
5
Posts: 173
Reputation: 4,742

Post » Wed Mar 21, 2012 2:35 pm

@Joe7: It all depends on what device you aim your game at.
For my game Drop Da Piew I used both Touch and Mouse, thinking the UI so everything is usable on both Touch and Desktop devices and using the mouse over to add a bit of eye candy when it is supported.

If you are sure you won't need the specificities of the mouse plugin, yes you can only use the Touch plugin and it makes it very convenient, with the very same code you have the very same behaving on touch and desktop devices.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Wed Mar 21, 2012 11:26 pm

Ok Kyatric, I'l see what works better but i believe that your way will be a lot faster because for the last few hours i have been doing it the way were you incest new sprites for every time i want a new stone or piece of gold.
B
12
S
1
Posts: 18
Reputation: 824


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests