OK hopefully not overkill here but this exhibits the issue. Thanks again.
–
– main.lua
local perspective = require(“perspective”)
local camera = perspective.createView()
local background = display.newImageRect( “background.png”, 10000, 10000 )
background.x = display.contentCenterX
background.y = display.contentCenterY
moveQueue={}
totMoves=3
score=0
local function initTbls()
for i=1, totMoves do
moveQueue[i]={}
moveQueue[i].ttMove=0
moveQueue[i].points=0
end
coroutine.yield()
end
function InitPlayer()
playerObj = display.newRect(160, 240, 10, 10 )
playerObj.alpha = 0.8
playerObj.gravityScale=0
camera:add(playerObj,1)
end
local function initTestJuncts()
P1 = display.newRect (160,40,2,2)
P1:setFillColor(1, .5, 0)
camera:add(P1,1)
P2 = display.newRect (0,40,2,2)
P2:setFillColor(1, .5, 0)
camera:add(P2,1)
P3 = display.newRect (0,120,2,2)
P3:setFillColor(1, .5, 0)
camera:add(P3,1)
end
camera.x, camera.y = 0, 80
camera.damping = 10
camera:add(background,1)
local function truncIT(t)
return math.round(t*10)*0.1
end
local function initDispCoords()
coordDisplayX = display.newText(truncIT(playerObj.x), display.contentCenterX, -40,native.systemFont, 10)
coordDisplayY = display.newText(truncIT(playerObj.y), display.contentCenterX, -30, native.systemFont, 10)
scoreDisplay = display.newText(truncIT(score), display.contentCenterX, -15, native.systemFont, 15)
end
local function DispCoords()
coordDisplayX.text = (truncIT(playerObj.x))
coordDisplayY.text = (truncIT(playerObj.y))
end
local function moved()
scoreDisplay.text=(truncIT(score))
print(" moved")
end
local initT = coroutine.wrap(initTbls)
initT()
InitPlayer()
initDispCoords()
Runtime:addEventListener( “enterFrame”, DispCoords)
local function testMoveQueue()
delay=0
deltaX=playerObj.x
deltaY=playerObj.y
for i=1,3 do
deltaX = deltaX + moveQueue[i].xMove
deltaY = deltaY + moveQueue[i].yMove
score=score + moveQueue[i].points
transition.to (playerObj, {x=deltaX, y=deltaY, time=moveQueue[i].ttMove, delay=delay, onComplete=moved} )
delay = delay + moveQueue[i].ttMove
print(“delay=”…delay)
end
end
camera:setFocus(playerObj)
camera:track()
camera:snap()
initTestJuncts()
playerObj.speed=0.1
moveQueue[1].xMove=0
moveQueue[1].yMove=-200
moveQueue[1].ttMove=200/playerObj.speed
moveQueue[1].points=20
moveQueue[2].xMove=-160
moveQueue[2].yMove=0
moveQueue[2].ttMove=160/playerObj.speed
moveQueue[2].points=16
moveQueue[3].xMove=0
moveQueue[3].yMove=80
moveQueue[3].ttMove=80/playerObj.speed
moveQueue[3].points=8
testMoveQueue()