Can someone explain what’s happening here. If I run this on my iPad 1, it prints the text ‘drawing lines’ every time, but it doesn’t draw the lines every time. This is set up to draw and print every 3 seconds. If it works every time for you, try restarting the program or change the for loop to 10, 15, or 20 and try again. This is a small example of something similar that was happening in another program I was working on. I can’t figure out why sometimes the lines are drawn and sometimes they not.
function setup()
et=0
end
function draw()
background(40, 40, 50)
fill(255)
text(math.floor(ElapsedTime),300,800)
if ElapsedTime-et > 3 then -- draw lines and print text every 3 seconds
stroke(255)
strokeWidth(2)
for z=1,15 do -- change value to 10,15,or 20
line(200+z*5,200,200+z*5,600) --draws 10, 15, 20 lines
end
print("drawing lines")
et=ElapsedTime
end
end
How many iterations does it take for the non-drawing behaviour to show itself? I just tried it on my iPad4 (though I am running the beta) and it seemed to work as I would expect.
.@Andrew_Stacey Sometimes it happens as soon as the program starts, sometimes after a few displays, and sometimes not at all. I think I have the answer. I just needed to sleep on it because when I woke up this morning I remembered a program I wrote a long time ago that might explain what’s happening. As soon as I find my original program and the discussion, I’ll share the answer if it’s what I’m thinking.
edit: I haven’t found what I’m looking for yet and I don’t have time right now. Here’s what I think is happening. Codea uses 3 screens for it’s display and 1 of those 3 screens is shown while the other 2 are being updated. My display is being drawn on 1 of the screens, but because the duration of the draw is so short, it isn’t being shown and being erased before the screen I wrote it to is shown. Like I said, I wrote a program that shows this, I just have to find it.