Hello. Here is some pretty simple code -
--Hide status bar from the beginning display.setStatusBar( display.HiddenStatusBar ) -- forward references local centerX = display.contentCenterX local centerY = display.contentCenterY local jitterUp local jitterDown -- create the display object/button local bgImg = display.newImageRect( "images/start.png", 173, 170 ) bgImg.x = centerX bgImg.y = centerY bgImg:scale(.6,.6) --move down local jitterDown = function (obj) transition.to (bgImg, {x=centerX, y=centerY +3, time=50, onComplete=jitterUp}) end -- move up local jitterUp = function (obj) transition.to (bgImg, { x=centerX, y=centerY -3 , time=50, onComplete=jitterDown }) end -- call functions jitterDown() jitterUp() timer.performWithDelay( 50, jitterDown, -1 ) timer.performWithDelay( 50, jitterUp, -1 )
The code works just fine - I am trying to find a way to add random movement of the “jittering” effect. I already tried to go into the transition.to statements and insert “y=math.randomseed(-3,3)”, but it does not work. I’m trying to randomize the Y position of the transition.to statements. No luck, yet.
Please help me figure this out. Thanks a lot, community!