Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

isShake bug =(
Started by nhong1991 Aug 01 2013 03:38 PM

7 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

nhong1991

[GLOBAL: userInfoPane.html]
nhong1991
  • Observer

  • 23 posts
  • Corona SDK

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)


[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,649 posts
  • Enterprise

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



[TOPIC: post.html]
#3

nhong1991

[GLOBAL: userInfoPane.html]
nhong1991
  • Observer

  • 23 posts
  • Corona SDK

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.

[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,649 posts
  • Enterprise

You are probably going to have to post more code.



[TOPIC: post.html]
#5

nhong1991

[GLOBAL: userInfoPane.html]
nhong1991
  • Observer

  • 23 posts
  • Corona SDK

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)


[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,649 posts
  • Enterprise

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

 

Thanks

Rob



[TOPIC: post.html]
#7

nhong1991

[GLOBAL: userInfoPane.html]
nhong1991
  • Observer

  • 23 posts
  • Corona SDK

[code_deleted]

Figured a solution.



[TOPIC: post.html]
#8

nhong1991

[GLOBAL: userInfoPane.html]
nhong1991
  • Observer

  • 23 posts
  • Corona SDK

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




[topic_controls]
[/topic_controls]