HELP! trying to build a 'highlight' system without using timers

bazookaBenbazookaBen Member Posts: 318
edited April 2012 in Working with GS (Mac)
i have a menu with 5 items, alpha set to 0.25

5 global variables are set to match the 5 items:
- item1active
- item2active
- item3active
- item4active
- item5active

Upon clicking one of the items, it highlights (alpha set to 1). All other items will de-highlight.

to achieve this effect, i use timers. Each item has a timer which refreshes every 0.25 seconds, and detects if one of the items is highlighted.

for eg, the logic for item1 is:

for each 0.25 seconds, if NOT item1active, set its alpha to 0.25 to dehighlight
else, set its alpha to 1

the thing is, if i have 50 items, i'll need 50 timers, which makes the app definitely SLOW :(

any ideas?

Answers

  • morphinegamingmachinemorphinegamingmachine Member, PRO Posts: 449
    make one game attribute called # item selected. and one self attribute # am i
    set each actor to the correct # am i attribute 1-50 in your case

    make each item have a rule if touch is pressed change (game.# item selected) to (self.# am i)

    new rule
    if (game.# item selected)=(self.# am i)
    change aplah to 1

    and add this to the
    otherwise section
    change alpha to .25

    this works if you only have one thing you need high lighted at a time. do you need more then one at a time?
  • bazookaBenbazookaBen Member Posts: 318
    edited April 2012
    It's simple: just drag the behaviors out of the timer.
    This will make it do it constantly, but timers are still less efficient at the moment.
    dragging the behaviors out of the timer will only make it execute once, when the item spawns.
  • bazookaBenbazookaBen Member Posts: 318
    make one game attribute called # item selected. and one self attribute # am i
    set each actor to the correct # am i attribute 1-50 in your case

    make each item have a rule if touch is pressed change (game.# item selected) to (self.# am i)

    new rule
    if (game.# item selected)=(self.# am i)
    change aplah to 1

    and add this to the
    otherwise section
    change alpha to .25

    this works if you only have one thing you need high lighted at a time. do you need more then one at a time?

    doesn't work unfortunately. i need only 1 thing highlighted at a time, but the timer needs to be present to continuously check for user activity ( if user clicks on another button ). Try it yourself.

    i'm trying to devise a timer-free method.

  • morphinegamingmachinemorphinegamingmachine Member, PRO Posts: 449
    um no, mine works for having one thing selected. ill make a demo
  • bazookaBenbazookaBen Member Posts: 318
    um no, mine works for having one thing selected. ill make a demo
    ok thanks! desperately need the demo
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    I can knock a demo up now if you need it right away?

    Ace
  • morphinegamingmachinemorphinegamingmachine Member, PRO Posts: 449
    it makes you just have one selected at a time, you can add more to it if you want to be able to deselect or have none highlighted
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    I see you're in good hands ;)
  • morphinegamingmachinemorphinegamingmachine Member, PRO Posts: 449
    did you check it out ace? it took about 3 min, and 2 of those were picking random icons from my other projects

    pretty sure its the most efficient way, if you can confirm or deny id be happy to learn :)

    btw ace I've tried to find your music and games? googling your name didn't come up with them... do you have a site where it displays it?
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    edited April 2012
    I didn't but I'm downloading it now.

    My band is called Ellerker - http://www.ellerker.net and here's a sneaky preview of our latest video that's no where near finished - a drum fill is out of time, the chants ending is too cheesy and a few other bits and bobs need changing:



    As for apps, I used to have an account on iTunse in my brother's name, now he just uses it for whatever he uses it for as I've set up mynameisace ltd. and going to be uploading new apps to there. Most of the work I've been doing for the past 10-12 months have been paid work for other people.

    Ace
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    Just checked out the demo and yeah, it's exactly how I'd do it. As you know, there are a million different ways to do anything in Gamesalad, but this is probably the most efficient way.

    If you want to add a deselect, just change the current touch is pressed behaviour to 'if touch is pressed and color.alpha = 0.25' then add in another rule saying when touch is pressed and color.alpha = 1 change attribute "game.whatever the attribute is called that matches to the self attribute" to 0.

    Ace
  • morphinegamingmachinemorphinegamingmachine Member, PRO Posts: 449
    song reminds me of anberlin. i used to love that band, i kind of like the chanting haha
  • crazyfishdevcrazyfishdev Member Posts: 283
    @mynameisace What do you play in the band?
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    Lead guitar ;)

    Ace
Sign In or Register to comment.