Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8571719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:50:35+00:00 2026-06-11T18:50:35+00:00

I have a fade-in/fade-out function based on a shake event, but if you shake

  • 0

I have a fade-in/fade-out function based on a shake event, but if you shake it again during the function, it stacks the functions. What I would like is for it to wait until the function ends (5 seconds) and then being listening again. What would the code be for that?

This is what I have currently:

function fadeOut ( event )
    transition.to(yes1, {time=2000, alpha=0})
    transition.to(yes2, {time=2000, alpha=0})
    ...
    transition.to(funny3, {time=2000, alpha=0})
    transition.to(funny4, {time=2000, alpha=0})
    timer.performWithDelay(2000, onShakeComplete)
end

responses = {yes1, yes2, yes3, yes4, yes5, yes6, yes7, yes8, yes9, yes10,
no1, no2, no3, no4, no5, maybe1, maybe2, maybe3, maybe4, maybe5,
funny1, funny2, funny3, funny4}

local shaking = false

-- reset shaking flag after a shake is completed
local function onShakeComplete()
    shaking = false
end

local function onShake (event)
        if event.isShake and not shaking then
        shaking = true
        local object = responses[math.random(1,20)]
        transition.to(object, {time=2000, alpha=1})
        timer.performWithDelay(4000, fadeOut)
    end
end
Runtime:addEventListener("accelerometer", onShake)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:50:37+00:00Added an answer on June 11, 2026 at 6:50 pm
    -- true if we have a shake happening right now
    local shaking = false
    
    -- reset shaking flag after a shake is completed
    local function onShakeComplete()
        shaking = false
    end
    
    local function onShake (event)
        if event.isShake and not shaking then
            local object = responses[math.random(1,20)]
            transition.to(object, {time=2000, alpha=1})
            timer.performWithDelay(4000, fadeOut)
            timer.performWithDelay(4000, onShakeComplete)
            shaking = true
        end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based on this question Fade in/out text based upon value of counter I have
I want to have a div fade in onClick , and fade out again
I've got a function that resizes images based on some criteria and would like
I have LI that I want to fade out and back in. Within the
I have a slider that has a fade-in and fade-out transition. It basically cycles
I have a pop-up window in jQuery that fades in, and will fade out
I have been trying to make a div fade in evey 30sec and out
I have 3 divs i want to fade in, then out and once they
I have the following code TransitionManager.start(babyPreloader,{type:Fade, direction:Transition.OUT, duration:0.5, easing:Regular.easeOut}); var tempPreloader:DisplayObject = babyPreloader as
I have a group of fade out animations, after which I want to run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.