Slow down animation with a button press

Hi.

I'm having some issues with slowing down the speed of my scrolling back ground with a button press and then restoring the original speed once you depress. So far I've been using simple Transitions that loop once they go a curtain distance off the screen.

This has not been working for me, I just get choppy breaks and it does not restore to the correct position.

Any help would be appreciated!

1
2
3
4
5
6
7
8
9
10
11
12
local function speedChange(event)     
        
        if event.phase == "began" then
 
                        mountain_big.x = mountain_big.x - xOffset*0.100
 
        elseif ( event.phase == "ended" or event.phase == "canceled" ) then
 
                        mountain_big.x = mountain_big.x - xOffset
 
        end
end 

Rather than the way your doing it.

Create a speed variable

ie :

1
local speed = 1

How exactly would I assign this variable? I'm using some of the code from the Horse animation template.

changing the "xOffset" changes the speed of that layer

Thanks!

1
local xOffset = ( 0.2 * tDelta )

Something like (code below should work out of the box) :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
local offSets = {
     [1] = {x = 0.2 * tDelta *0.100},
     [2] = {x = 0.2 * tDelta},
}
 
local theOffset = offSets[1].x
 
local function speedChange(event)     
        
        if event.phase == "began" then
            theOffSet = offSets[1].x 
        elseif ( event.phase == "ended" or event.phase == "canceled" ) then
            theOffSet = offSets[2].x 
        end
 
         mountain_big:translate(-theOffSet, 0)
 
        return true
end 
views:1443 update:2011/12/30 9:10:41
corona forums © 2003-2011