and try to draw an ellipse at CurrentTouch.x, CurrentTouch.y in the draw function, the ellipse doesn’t stay where I drew it. Instead, it moves left with each successive redraw.
firstTime = true
frameCount = 0
oldX = -1
oldY = -1
displayMode(FULLSCREEN)
backingMode(RETAINED)
function setup()
end
function draw()
if firstTime then
background(40, 40, 50)
if (frameCount>1) then
firstTime = false
end
end
stroke(255,255,255,255)
strokeWidth(5)
if frameCount > 0 and oldX ~= -1 then
drawLines(oldOldX, oldOldY, oldX, oldY)
else
if CurrentTouch.state == MOVING then
if oldX == -1 then
oldX = CurrentTouch.x
oldY = CurrentTouch.y
end
drawLines(oldX,oldY,CurrentTouch.x,CurrentTouch.y)
oldOldX = oldX
oldOldY = oldY
oldX = CurrentTouch.x
oldY = CurrentTouch.y
elseif CurrentTouch.state == ENDED then
oldX = -1
oldY = -1
end
end
frameCount = frameCount + 1
if frameCount > 2 then
frameCount = 0
end
end
function drawLines(x1, y1, x2, y2)
line(x1, y1, x2, y2)
line(WIDTH-x1, y1, WIDTH-x2, y2)
line(x1, HEIGHT-y1, x2, HEIGHT-y2)
line(WIDTH-x1, HEIGHT-y1, WIDTH-x2, HEIGHT-y2)
end
Comment out the “displayMode(FULLSCREEN)” line and you’ll see how it is supposed to behave.
I have pad (2) iOS(5) and Codea(1.41).
Always best to quote these when you’ve got a problem - it will help Simeon and the Codea team to identify your problem and, more importantly, how to resolve it.
I also discovered that FULLSCREEN is in orange (as it should be) while RETAINED is not. I realize it has nothing to do with this issue, but it is still a minor bug.
Yes, a project I’ve been working on for the last few days presented me with this. They way I worked around it was by creating a boolean variable that controls the background() function, causing it to draw only once when the application first runs. Which is similar to what you did in your code, but by counting frames, so I don’t know why yours doesn’t work…
function setup()
displayMode(FULLSCREEN)
backingMode(RETAINED)
…
setBackground = true
…
end
function draw()
…
if setBackground == true then
background(255)
setBackground = false
end
…
end
Hope this helps. Any better ideas of how to do this are welcome.
The problem isn’t controlling when the background is cleared. The problem is that nothing stays where it was drawn. Each update seems to be scaling everything down in the x axis, which moves it to the left.
I just upgraded Codea and the problem is still present on my iPad 3.
I’ve been struggling with this too. It has made me regret upgrading to an iPad 3, since I bought it specifically to work on a Codea project that is now on hold because of this bug.
And here’s a quick example of the effect – swap between the two displayMode settings in setup() on an iPad 3, and with FULLSCREEN you’ll get the “things fly leftward” problem:
function setup()
displayMode(FULLSCREEN)
-- displayMode(STANDARD)
backingMode(RETAINED)
fill(0,255,0,255)
end
function draw()
if (CurrentTouch.state==BEGAN or CurrentTouch.state==MOVING) then
ellipse(CurrentTouch.x, CurrentTouch.y, 100)
end
end
Simeon, have you been able to check in with Apple about this one?