isShake bug =(

Hi,

I have a isShake listener and inside of it, I want it to set some booleans to true and false. It seems to not be working properly. Any help would be greatly appreciated.

true01 = true

true02 = true

true04 = false

true04 = false

timeOf_Shake

local function setBool (event)

    if (event.isShake) then

        

        true01 = false

        true02 = false

        true03 = true

        true04 = true

        timeOf_Shake = system.getTimer() + 2000

    end

    return true

end

Runtime:addEventListener (“accelerometer”, setBool)

I would recommend putting in some prints to make sure you’re actually getting the event your expecting.

I tries that, it triggers and removed a bunch of things but does not set off my boolean. I have a timer.delay function that check the values and call it’s respective function based on the boolean.

You are probably going to have to post more code.

the rest of the code

true01 = true

true02 = true

 

true04 = false

true04 = false

local spreatSheet = sprite.newSpriteSheet (“someSprite”, 100,100)

local objSheet = sprite.newSpriteSheet (spreatSheet, 1, 30)

sprite.add (objSheet, 1, 30, 1000, 0)

local spreatPlay = sprite.newSprite (objSheet)

function updateSheet ()

         if (true01 == true) then

               if (true02 == true) then

                   spreatPlay:removeSelf()

                   true02 == false

                   loadAnotherImage_InThisFunction_AndPlay()

                end

          

          elseif (true03 == true) then

                  if (true04 == true) then

                       spreatPlay:removeSelf()

                       loadAnotherImage_DifferentFrom_Above()

                       true04 == false

                   end

          end

end

timer.performWithDelay ( 1, updateSheet, 0)

local function setBool (event)

    if (event.isShake) then

        

        true01 = false

        true02 = false

 

        true03 = true

        true04 = true

        timeOf_Shake = system.getTimer() + 2000

    end

    return true

end

Runtime:addEventListener (“accelerometer”, setBool)

Looks like you’re missing some code.  Also please paste it in between ** and ** tags (using square brackets and leaving out the space after the opening square bracket.

Thanks

Rob

[code\_deleted]

Figured a solution.

ideally, I wanted a default animation, then when shaked, it plays another for 2-3 seconds then just goes back to normal

I would recommend putting in some prints to make sure you’re actually getting the event your expecting.

I tries that, it triggers and removed a bunch of things but does not set off my boolean. I have a timer.delay function that check the values and call it’s respective function based on the boolean.

You are probably going to have to post more code.

the rest of the code

true01 = true

true02 = true

 

true04 = false

true04 = false

local spreatSheet = sprite.newSpriteSheet (“someSprite”, 100,100)

local objSheet = sprite.newSpriteSheet (spreatSheet, 1, 30)

sprite.add (objSheet, 1, 30, 1000, 0)

local spreatPlay = sprite.newSprite (objSheet)

function updateSheet ()

         if (true01 == true) then

               if (true02 == true) then

                   spreatPlay:removeSelf()

                   true02 == false

                   loadAnotherImage_InThisFunction_AndPlay()

                end

          

          elseif (true03 == true) then

                  if (true04 == true) then

                       spreatPlay:removeSelf()

                       loadAnotherImage_DifferentFrom_Above()

                       true04 == false

                   end

          end

end

timer.performWithDelay ( 1, updateSheet, 0)

local function setBool (event)

    if (event.isShake) then

        

        true01 = false

        true02 = false

 

        true03 = true

        true04 = true

        timeOf_Shake = system.getTimer() + 2000

    end

    return true

end

Runtime:addEventListener (“accelerometer”, setBool)

Looks like you’re missing some code.  Also please paste it in between ** and ** tags (using square brackets and leaving out the space after the opening square bracket.

Thanks

Rob

[code\_deleted]

Figured a solution.

ideally, I wanted a default animation, then when shaked, it plays another for 2-3 seconds then just goes back to normal