Good Day I think I found a bug on the function “object:scale”
my object is being animated on runtime by changing it’s scale to .3 to 2. I used the scale function, but I think there is a bug. What I did is, for every 1 second I will spawn a new Object, that will increase it’s scale per frame. The spawning is okay, but the problem is, the first object is the only that changes scale, it must be removed before the next object’s scale is change, and it will continue. I solved this buy manually changing the scale, here are my codes: Daily Build v2017.3032 (2017.2.7)
The Error one(“object:scale()”)
local ms = movementSpeed local timerFrames = 0 local newLayer = newImageRectNoDimensions(bgLocation..levelNumber.."/"..math.random(1,4)..".png") newLayer.width = \_W newLayer.height = \_H newLayer.x = \_W/2 newLayer.y = \_H/2 newLayer.xScale = .3 newLayer.yScale = .3 newLayer.withRuntime = true movementGroup:insert(newLayer) newLayer:toBack() function newLayer:enterFrame(event) local dt = getDeltaTime() local newScale = 1 + (ms\*dt) if newScale \> 2 then newScale = 1 end self:scale( newScale, newScale ) end local function changeGradually( event ) -- body print(timerFrames) timerFrames = timerFrames + 1 if timerFrames \> 12 then ms = ms + 0.0005 end end timer.performWithDelay( 1, changeGradually,50 ) Runtime:addEventListener( "enterFrame", newLayer ) transition.to(newLayer,{time = 5000, onComplete = remover})
Working Version:
local ms = movementSpeed local timerFrames = 0 local newLayer = newImageRectNoDimensions(bgLocation..levelNumber.."/"..math.random(1,4)..".png") newLayer.width = \_W newLayer.height = \_H newLayer.x = \_W/2 newLayer.y = \_H/2 newLayer.xScale = .3 newLayer.yScale = .3 newLayer.withRuntime = true movementGroup:insert(newLayer) newLayer:toBack() function newLayer:enterFrame(event) local dt = getDeltaTime() -- self:translate( 0, 1 \* dt) -- local newScale = 1 + (ms\*dt) -- if newScale \> 2 then -- newScale = 1 -- end -- self:scale( newScale, newScale ) self.xScale = self.xScale + .01 self.yScale = self.yScale + .01 end local function changeGradually( event ) -- body print(timerFrames) timerFrames = timerFrames + 1 if timerFrames \> 12 then ms = ms + 0.0005 end end timer.performWithDelay( 1, changeGradually,50 ) Runtime:addEventListener( "enterFrame", newLayer ) transition.to(newLayer,{time = 5000, onComplete = remover})