New Scene-Simple Text Scale Animation Not Working?

Hi,

Trying to make a text scale in and out in a new scene, but it’s not animating at all (displays ok at default scale)?

-- "main.lua" TextScale = 1 TextScaleDir = 1 local composer = require( "composer" ) composer.gotoScene( "sceneAnimatedTextTest" )

-- "sceneAnimatedTextTest.lua" local composer = require( "composer" ) local scene = composer.newScene() -- ------------------------------------------------------------------------------------------------------------- function scene:create( event ) local sceneGroup = self.view TextScale = 1 TextScaleDir = 1 myRectangle = display.newRect( display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight ) myRectangle.strokeWidth = 5 myRectangle:setFillColor( 0.5 ) myRectangle:setStrokeColor( 0, 1, 0 ) displayText = display.newText( "Hello World", display.contentCenterX, display.contentCenterY, "Font01.ttf", 20 ) displayText:setFillColor( 0, 1, 0 ) end -- ------------------------------------------------------------------------------------------------------------- function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then if TextScaleDir == 1 then if TextScale \<= 5 then TextScale = TextScale + .1 else TextScaleDir = 0 end elseif TextScaleDir == 0 then if TextScale \>= 0 then TextScale = TextScale - .1 else TextScaleDir = 1 end end displayText:scale( TextScale, TextScale ) end end -- ------------------------------------------------------------------------------------------------------------- function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- ------------------------------------------------------------------------------------------------------------- function scene:destroy( event ) local sceneGroup = self.view end -- ------------------------------------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ------------------------------------------------------------------------------------------------------------- return scene

This is my first day using Corona SDK & Lua.

Any help would be appreciated, thanks!

JeZxLee

The display is probably updating so fast you can’t see it change the scale. If it all can happen in a single frame, you will only get one update with the total update.

If you want to visually see it scale down, consider using a transition.to() function and having it iterate the scale over time.

Rob

The display is probably updating so fast you can’t see it change the scale. If it all can happen in a single frame, you will only get one update with the total update.

If you want to visually see it scale down, consider using a transition.to() function and having it iterate the scale over time.

Rob