I’m working on a page-turning routine – and the code drawing the turning page goes into a mad redrawing loop even when it should stop.
(It draws the sprite at the finger touch location)
Code follows – simplified to show the problem. Any ideas what the problem is?
-- Use this function to perform your initial setup
sprite("Cargo Bot:Codea Icon",0,0,WIDTH,HEIGHT)
pager = image(WIDTH/2,HEIGHT)
if CurrentTouch.state == BEGAN or
CurrentTouch.state == MOVING then
lastDelta = CurrentTouch.deltaX*-1
if tp>midX then
elseif tp>0 then
between function draw() and drawPage()
thanks – that worked.
But What caused the problem? specifically the random redrawing? I assumed backingMode(STANDARD) would start with a blank buffer – but I’m guessing it only assumes the code is responsible for display buffer updates – and the “random” redraws was really buffermemory artifacts?
.@akiva that is correct. The standard backing mode assumes that the screen will be cleared before draw. We could do this automatically but it’s less optimal in the case where you completely fill the screen each frame. Perhaps we still should do this automatically when standard backing mode is used.
Hi Simeon. Thanks for the clarification. You might want to mention this in the docs.
Why not make it an optional flag? I.E. backingMode(STANDARD,BLANK) would zero out the background (Or make BLANK a color value), while backingMode(STANDARD) wouldn’t.
That’s a good idea about adding a new backingMode. Perhaps we’ll do the opposite in terms of parameters, though:
backingMode(STANDARD) always clears, whereas backingMode(NO_CLEAR) lets you handle clearing.