How do I get all arrows to show?

0 favourites
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hey C3 world!

    Decided to do some testing to learn more about conditions. In this scenario, an easy "left-arrow" if cows = 3, otherwise a "right-arrow" should appear. However the arrows don't stay visible once I click on another sprite.

  • They don't stay visible because you're destroying them in events 5 and 6.

  • Ah, I see! How would I keep them visible? I thought the "pick instance...UID" condition would do the trick. Subsequent testing including sub-events hasn't fixed it either so it's a "me not knowing" issue. Thanks for your help.

  • Is this an acceptable answer? I got it working but wasn't sure if it was what would be recommended.

  • I can definitely say what you have is not recommended, because you're going to be spawning arrows every tick.

    If I were to do it, it would be...

    On clicked - destroy all arrows

    then in subevents

    If sprite cows <= 2, spawn rightarrow,

    Else, spawn leftarrow

    But that depends on what your end goal is. If you can clearly describe what you are trying to do in writing, you'll be able to narrow down what events are necessary as well.

  • Here is an update. I realized after reading your post that arrows would just continue to be created, great catch! I hadn't used debug view as often as I should and seeing how valuable it is, it's a must-do.

    No matter how I set this, I can't get this to work without create a gazillion objects. I want to prevent assigning less than 0 and more than 3 to the sprite.cows instance variable.

    If cows =0, right arrow shows, only increase button shows.

    If cows <=2, right arrow shows, increase/decrease buttons show.

    Cows =3, left arrow shows, only decrease button shows.

    I tried creating them with trigger once, setting the condition to detect if they were visible/existing/on-screen, and now on disable/enable. Nothing has worked. Suggestions?

  • There will always be an arrow. Every time you click, the old one will be destroyed and a new one created in the correct direction.

  • There will always be an arrow. Every time you click, the old one will be destroyed and a new one created in the correct direction.

    Just missed your post while testing and rewriting a follow-up.... Sorry.

    Here is an update. I realized after reading your post that arrows would just continue to be created, great catch! I hadn't used debug view as often as I should and seeing how valuable it is, it's a must-do.

    No matter how I set this, I can't get this to work without create a gazillion objects. I want to prevent assigning less than 0 and more than 3 to the sprite.cows instance variable.

    If cows =0, right arrow shows, only increase button shows.

    If cows <=2, right arrow shows, increase/decrease buttons show.

    Cows =3, left arrow shows, only decrease button shows.

    I tried creating them with trigger once, setting the condition to detect if they were visible/existing/on-screen, and now on disable/enable. Nothing has worked. Suggestions?

  • progress!! I either create a million (remove trigger once) or none (add trigger once)...

  • Is there a particular reason you have to create and destroy your interface objects? Based on your requirements only, here's how I would do it.

    dropbox.com/s/wm6xq42irqgakks/buttonstates_example.c3p

  • Is there a particular reason you have to create and destroy your interface objects?

    Sadly no, no particular reason beyond being a newb and not very versed. :)

    Thank you for the example! I am reverse-engineering it now..

  • quick dumb question, how did you use a dif animation on the sprite in the layout page (plus and minus images)?

  • 'Initial Frame' in object properties.

  • 'Initial Frame' in object properties.

    This seems to be one of those "teach a man to fish...." sort of experiences as you've completely changed the way I approach the coding of this game. The example you provided was a tremendous help and not sure anyone has provided that for me before...thank you!)

    If this project ever gets big, I'll make sure you get the credit (maybe oosyrag will be a secret code word somewhere in this..)

    Final version (unless you see something I need to tweak)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's not a big deal in this situation, but as a general good practice don't let any event run every tick if it doesn't need to (event 5).

    Basically your objects don't need to change unless sprite.cows changes, and sprite cows will only change on user input.

    So in this case I'd probably make it a function that gets called as an action in events 9 and 10.

    Normally though, I would put the whole thing as a subevent of a trigger if I could, similar to what I did in my example.

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