breaking switch case

This forum is currently in read-only mode.
From the Asset Store
Toggles Dials Switches and Alerts ! A foundational sound grouping of Analog type switches and Steampunk effects
  • 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

  • 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.

  • 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

  • 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:

    <img src="http://dl.getdropbox.com/u/666005/TD02.jpg">

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • mangament wHA!!! game

    your giving construct a bad image! lol

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)