breaking switch case

For questions about using Classic.

Post » Mon Aug 24, 2009 6:38 pm

Hello all, I've been reading the forum and the wiki for quite some time ninja style. First I want to thank the developers for putting Construct up, because I'm quite programming impaired, and Construct makes it fun and easier. I decided to try to make a management hentai game and it happens that I cannot solve a problem even after searching everywhere.

What is going on is that, on the click of a button, a private variable in a placeholder sprite is checked for a certain state. Some sprites have this state, while others do not (that is decided on the previous layout). And I want that for each sprite with that state do different specific actions, change the state, and at the same break the whole loop.

in simpler words, the actions of the first picked sprite must be the only ones being executed. If at one time one sprite is picked, all the other actions for other sprites should be excluded even if they meets the condition of the triggering state.
If I do a "For Each" all sprites with the triggering state will be picked at the same time. I tried placing various Else's (with a condition right next to it) but it only executed the first else, the subsequent elses were ignored. I also tried to do a On Loop and placing subevents for each case, and on each of the actions for them I placed a Break current loop, but they all showed at the same time.

I found that in C++ this works with a switch case command, where in each case, the switch loop is broken with a break command.

Hope I'm making myself clear. thank you for your help :wink:
B
2
G
3
Posts: 7
Reputation: 864

Post » Mon Aug 24, 2009 7:57 pm

I not sure if I'm getting what you want to do, but let me try... :?

So you want one sprite being picked, do some actions on this sprite (and on this sprite only) and other sprites which may meet the coniditions will be ignored after that?! You could simply use a global (or any variable) to check how many times the For each loop already ran, and stop it after 1 run. But that's pretty simple, so I'm quite sure that I missed your point. Maybe you could share a cap. That might clarify things. Or wait for the bright ppl to reply. :mrgreen:
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Mon Aug 24, 2009 9:23 pm

no, im pretty sure thats what he meant pixel. welcome to construct, triplehex.

unfortunately, there is no way to break a "for each" loop. you just have to make a global variable as he said. set it to 0 before the loop.set it to 1 as part of the event's actions if a sprite triggers the condition and have the condition include a check to see if the global variable is equal to 0 as part of the conditions to trigger the loop
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Mon Aug 24, 2009 10:48 pm

that's it =D

I'll post the cap in the upload section for those interested.
for those who want to see what it looks like now without downloading the cap, here it is:
B
2
G
3
Posts: 7
Reputation: 864

Post » Wed Aug 26, 2009 12:03 am

mangament wHA!!! game :shock:
your giving construct a bad image! lol
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests