This is supposed to show two images that move in a circle as you swipe the screen.
The first image moves in a circle along the x and y axes, and it works just fine.
The second moves along the x and and z axes, and it blinks in and out of visibility as it goes.
Can anyone point out my error?
function setup()
angle = 0
-- Mesh to rotate on x and y axes
radius = 60
centerX = WIDTH * 0.25
centerY = HEIGHT / 2
mesh1 = mesh()
mesh1:addRect(0, 0, 100, 100)
mesh1.texture = asset.builtin.Environments.Night_Back
-- Mesh to rotate on x and z axes
radius2 = 3.5
centerX2 = WIDTH * 0.55
centerZ = 10
mesh2 = mesh()
mesh2:addRect(0, 0, 100, 100)
mesh2.texture = asset.builtin.Environments.Sunny_Back
end
function draw()
background(40, 40, 50)
-- Calculate the position based on the angle
local x1 = centerX + radius * math.cos(angle)
local y = centerY + radius * math.sin(angle)
-- Calculate the position based on the angle
local x2 = centerX2 + radius2 * math.cos(angle)
local y2 = HEIGHT/2
local z = centerZ + radius2 * math.sin(angle)
pushMatrix()
translate(x1, y, 0)
mesh1:draw()
resetMatrix()
translate(x2, y2, z)
mesh2:draw()
popMatrix()
end
function touched(touch)
if touch.state == MOVING then
-- Adjust the angle based on the swipe
angle = angle + touch.deltaX * 0.01
end
end