How to Toggle something with click or key-press?

For questions about using Classic.

Post » Wed Oct 08, 2008 6:09 pm

Writing "4-1" provides information about "why this is 3?". You can say it's a calculation that documents code. When performance isn't vital in algorithms, I'd rather try to make code easier to understand.

It'd be the best if you created some sprite called "Conf" and put PV like "ElementsCount" and then done events like:
[code:1cjhwone]-> "UP" pressed: set value to (value + Conf('ElementsCount') - 1) % Conf('ElementsCount')
-> "DOWN" presset: set value to (value + 1) % Conf('ElementsCount')[/code:1cjhwone]
This'd be more flexible and useful for next appliactions.
B
6
S
3
G
6
Posts: 219
Reputation: 3,013

Post » Wed Oct 08, 2008 7:21 pm

[quote="BROO":pb77egcc]Writing "4-1" provides information about "why this is 3?". You can say it's a calculation that documents code. When performance isn't vital in algorithms, I'd rather try to make code easier to understand.[/quote:pb77egcc]
FYI, the runtime will simplify a constant expression (eg. 4 - 1 to 3) on startup, so you can always do this to make your expressions clearer without suffering any performance hit.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Wed Oct 08, 2008 11:27 pm

Thanks, that modulo thingy sure was helpful.

Now I just need a solution for my 2nd problem and I won't bother you guys for a while :)

[quote="Kr!s":3ayh4s8x]Also, If I click on something to take me to the next layout, and on that layout I have something on the same position as the previous object also with an action set when is clicked, that action happens immediately.[/quote:3ayh4s8x]
B
2
S
1
G
4
Posts: 92
Reputation: 1,384

Post » Thu Oct 09, 2008 12:02 am

[quote="Kr!s":1ezm0b5s]Also, If I click on something to take me to the next layout, and on that layout I have something on the same position as the previous object also with an action set when is clicked, that action happens immediately.[/quote:1ezm0b5s]

That sounds like something that should be fixed in Construct itself. As a workaround, you could set a variable in the Start of Layout that sets value"clicking" to "off" or something like that. Then in the events for your button clicks, add a condition that checks the status of the variable. After your button click events, set the variable to "on." That should work.

Kind of a hacky workaround, but hey, it should get the job done.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Oct 09, 2008 12:24 am

[quote="deadeye":2k2g0kj5]That sounds like something that should be fixed in Construct itself. As a workaround, you could set a variable in the Start of Layout that sets value"clicking" to "off" or something like that. Then in the events for your button clicks, add a condition that checks the status of the variable. After your button click events, set the variable to "on." That should work.

Kind of a hacky workaround, but hey, it should get the job done.[/quote:2k2g0kj5]

Lol, I was just trying that.
And yes, it looks like it's working so far!

But, anyway, it still is kinda lame that we must have this kind of workaround for something that should be simpler.

Thanks to everyone who helped me :D
B
2
S
1
G
4
Posts: 92
Reputation: 1,384

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest