Button vs Sprite clicking: Wrong Variable Increment

Just started using Construct 2? Post your questions here

Post » Fri Sep 02, 2016 2:19 am

In the below, if the BUTTON is clicked, CGStage has 1 added to its count.

If the Sprite is clicked, CGStage gets a random number added, somewhere between 5-7.

Is there some other condition I'm missing that makes Sprite-based buttons different than the Button object?

Image

I did see this thread https://www.scirra.com/forum/solved-thanks-add-1-to-count-yes-just-1-this-time_t181230 but I haven't gone into Families yet and I certainly don't want the Sprite-based button to be destroyed. In short, I got lost.
B
5
S
1
G
2
Posts: 6
Reputation: 1,337

Post » Fri Sep 02, 2016 2:32 am

Unless you've got multiples of the same sprite stacked on each other, should work the same.
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Fri Sep 02, 2016 2:36 am

Ah, now there's a thing. There is another sprite directly below that one but it's set to invisible. Guess I'll need to figure out a new way around that now. Didn't know you could still interact with invisible objects!
B
5
S
1
G
2
Posts: 6
Reputation: 1,337

Post » Fri Sep 02, 2016 2:53 am

Just add "Is visible" to the event.
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Fri Sep 02, 2016 3:06 am

Unfortunately it doesn't look like that works. From the manual:

Is visible
True if the object is currently visible. Invert to test if invisible. This only tests the visibility set by the Set visible action; it is not affected by the object being offscreen, having 0 opacity, or being on an invisible layer.

I was trying to make a menu system using a single layout that simply turns layers on or off (rather than constantly going to a new layout for no reason) based on what was clicked. It doesn't look like that's possible, or at least, beyond my current level of knowledge.
B
5
S
1
G
2
Posts: 6
Reputation: 1,337

Post » Fri Sep 02, 2016 3:45 am

You can correlate if the sprite is on a layer and if that layer is visible. It's all doable. Don't over-complicate though. If it's off screen, it can't be clicked on.
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Fri Sep 02, 2016 5:21 am

I figured out a way to do it, though it isn't perfect. It all operates on a single layer and once the CGStage variable is advanced, I simply use System Scroll to X. While it does make the layout pretty large, everything does work perfectly!
B
5
S
1
G
2
Posts: 6
Reputation: 1,337


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 4 guests