Pulsating button indicator
floatingwoo
Los Angeles, Calif.Member Posts: 393
Im using a simple ring to indicate a spot for the user to click on. I would like the ring to gradually come on and off (alpha up and down). I'm thinking interpolate with a timer but I can't seem to get my head around the logic. Heres what I've got....
Inside the circle graphic I've got one attribute.
buttonOn as a boolean
Change attribute: self.color.alpha_to_0
Rule:
When _attribute: game.time_=_2
Change attribute: self.button.on_to_true
Rule:
When _attribute: self.buttonOn_is_true
Timer:
After 2 seconds _run to is checked
Interpolate: self.color.alpha to 1
for 2 seconds
otherwise
Interpolate: self.color.alpha to 0
But obviously this ain't doing it for me or I wouldn't be asking for help...thanks
Comments
It could be that game.Time never actually reaches a value of 2. It may be 1.9987 or 2.01568 for example. It should be a bit simpler than that, anyway:
When attribute self.color.alpha=0
Interpolate self.color.alpha to 1 [duration: 2 seconds]
When attribute self.color.alpha=1
Interpolate self.color.alpha to 0 [duration: 2 seconds]
Are you wanting it to start two seconds after the game is previewed? And are you wanting any kind of pause between the two interpolations?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I think I got it...
Rule: when_attribute game .time_=_2
Rule: when_attribute: self.buttonOn_is _true
Yeah thats it! Mo simple!Thanks tatting!
Glad to hear it. I'm not sure what you have the self.buttonOn attribute but perhaps you're using that for something else.
Edit: you're welcome!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Taking inspiration from Socks' trig lessons thread - which explained to me (for the first time) how I could visualise Sin and Cos - try constraining the image alpha to thr following to make it pulse:
Change the value 40 to a lower number to slow down the pulse and higher to speed it up - then just run this rule after 2 secs.
Even better, @Matt Soden By the way, with a space in your name you won't receive forum notifications. I'll see if I can remove it ( @MattSoden , there!) but if it doesn't stick, send a private message to @ForumNinja.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Cheers tatiang
Wow! thats awesome! Works great. Thanks Is a constraint more cpu intensive?
I doubt it. My guess is that constantly interpolating and constantly constraining should be equally intensive.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Cool thanks!
I always thought that "constrain" is such an ominous term, as it is just a change attribute behaviour that will execute every code cycle.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Someone made it through the 'course' !
This is 'bouncing' the sine wave when it hits zero, maybe that was what you wanted, it looks kinda pulsey after all ! If you wanted to have a dampened return at each end (basically squash the whole range of the sine wave into 1 (as colour channels only operate from 0 - 1 and a sine operates from -1 to 1) . . it would be, constrain alpha to:
0.5 *sin(self.time *40)+0.5
Hold on, I feel we need a picture . . . back in a second . . .
@MattSoden
The top image is your version that is bouncing the sine wave when it hits zero, the bottom is cutting its range in half and then moving it up by half its height . . . both work as a pulse.
Oh yeah thats much nicer Thanks!
Like a light house on a foggy day....
Whats the name of the thread with @Socks trig lessons?
Working on something at the moment that could benefit from a re-education in the subject
It wasn't really a lesson, it was just another thread that got derailed into a sin/cos thing, but was abandoned in the end, there were no saviours.
Yeah, it's exactly like a lighthouse as its the amount of light you would see if the light source was revolvling.
@Socks yup..but which thread?
I remember liking the sin/cos tutorials/explanations you did, and could do to look at it again....
http://forums.gamesalad.com/discussion/74867/realistic-slots-moment-fall-in-to-place/p1