Make an actor flash on & off ?

InvisibleHamInvisibleHam Member Posts: 15
edited November -1 in Working with GS (Mac)
Hello all, hope everyone is doing great!

I was wondering if it's possible for an actor to be off screen but appear on screen for .1 seconds every 1 second?

Kind of like a flash that you see every second?

Hope this makes sense & thanks for any advice

Cheers

Comments

  • AfterBurnettAfterBurnett Member Posts: 3,474
    Yup :) You could use timers to change the self.alpha attribute.Not in front of GS right now (at work) and I'm so tired I couldn't tell you how to do it without looking inside GS but at least it's a place to start :)
  • AfterBurnettAfterBurnett Member Posts: 3,474
    Ooh! Ooh! You could also do what I did with a massive laser in my game. If the actor doesn't need different animation frames, you could use the animation behaviour to flash between the actor's image file and a blank .png file... that way you can adjust the frame rate depending on how fast you want it to "flash" :)
  • InvisibleHamInvisibleHam Member Posts: 15
    Thanks,

    Would that be a 'Change Attribute' inside of a 'Timer' behavior?

    I'm still feeling my way around, trying to learn what everything does.
  • InvisibleHamInvisibleHam Member Posts: 15
    Well maybe it will help if I explain a bit more what I'm trying to achieve:

    I basically have a guy that I want the user to tap to defeat. Only, the user needs to tap at precise intervals (to a beat) so I was thinking of having a transparent actor 'appear' on top of the guy every 1 second (to the beat) and if the user taps on the transparent actor, they get +100 points, but if they tap the guy (while the transparent actor isn't on top of him) they get -100

    does that make sense?

    Thanks again!
  • AfterBurnettAfterBurnett Member Posts: 3,474
    Yeah, use a timer - "EVERY 1 second, FOR 1 second, CHANGE ATTRIBUTE self.alpha to 0". Or something like that... not sure if that would work... brain is a little fried right now... 4:08am and I'm still at work. lol.
  • InvisibleHamInvisibleHam Member Posts: 15
    Hahah, no worries, I'll give that a shot and see how it works out.

    Thanks and get some rest!
  • AfterBurnettAfterBurnett Member Posts: 3,474
    Or: "Every 1 sec, if alpha=0, change to 1, otherwise if alpha =1, change to 0"
  • InvisibleHamInvisibleHam Member Posts: 15
    Doesn't seem to work, every combination I'm trying just either has it invisible or solid, no flashing.
  • AfterBurnettAfterBurnett Member Posts: 3,474
    Use two rules (otherwise can be a bit iffy):

    WHEN alpha=0, AFTER 1 sec, Change Attribute self.alpha to 1

    WHEN alpha=1, AFTER 1 sec, Change Attribute self.alpha to 0

    That should work.
  • AfterBurnettAfterBurnett Member Posts: 3,474
    Also, instead of using an invisible actor for detection, you could have an attribute named "Detectable" and have it to switch on and off. When it's on, the player's touch counts, when off, it doesn't. Be less processor intensive than a whole other actor ;-)
  • expired_012expired_012 Member Posts: 1,802
    First make a fade in boolean attribute in your actor that you want to flash. Name it "fadein"

    Rule:

    When self.color.alpha=1
    -change attribute (self.fadein) to false

    New rule:

    When attribute (self.fadein) is false
    -Interpolate self.color.alpha TO: 0
    DURATION: 1
    FUNCTION: LINEAR

    New rule:

    When attibute (self.color.alpha)=0
    -change attribute (self.fadein) to true

    New rule:

    when attribute (Self.fadein) is true
    Interpolate self.color.alpha to 1
    DURATION: 1
    fUNCTION: LINEAR
  • AfterBurnettAfterBurnett Member Posts: 3,474
    That'd fade it, though. I think he wants it to flash. For fading, could also use the method I put up there and swap out CHANGE ATTRIBUTE for INTERPOLATE, the less rules and attributes, the better.
  • expired_012expired_012 Member Posts: 1,802
    Oh i see now, i didn't know what he meant by flash but now i get it

    You could just use the same thing i posted but set the duration to to 0.1 or 0.001, etc depending on how fast you want the flash to be. It'll be going so fast that you cant notice its a fade, it would create a flashing effect
  • AfterBurnettAfterBurnett Member Posts: 3,474
    That's the cool thing about GS, many ways to do things :D
  • InvisibleHamInvisibleHam Member Posts: 15
    "Also, instead of using an invisible actor for detection, you could have an attribute named "Detectable" and have it to switch on and off. When it's on, the player's touch counts, when off, it doesn't. Be less processor intensive than a whole other actor ;-)"

    Could you tell me how to create attributes?

    Also I'm totally open to any better ways to do this. Just think of a rhythm game: I need hits to land on beats and when a user taps off-beat they lose points.

    The invisible actor flashing on and off was the first thing I thought of, since there obviously isn't any way for Gamesalad to recognize music files and detect rhythms :P

    Thanks again I am away from GS for now but I will try these out soon & report back

    Cheers!
  • AfterBurnettAfterBurnett Member Posts: 3,474
    Click on attributes in the scene editor and hit the little "+" button :)

    A rythym game could be tough in GS... the timers aren't perfectly accurate and GS tends to stutter every now and then for no apparent reason.
Sign In or Register to comment.