Scrolling screen, App crashes!

I wrote a code that would sprite images in a screen that can be scrolled. I made a localValue(which was Height/2 to begin with) equal to localValue+touch.deltaY, and sprited images in ‘draw()’. The game functions pretty well with no errors popping up: for about 5 seconds. :neutral:

I am thinking this is because I am trying to sprite the images in each frame and the memory just collapses. Could anyone give me any suggestions? Or tell me where I might refer to? Thanks.

if you share some code, it will be easier to help

@hohohohoho Are you trying to do something like this.

displayMode(FULLSCREEN)

function setup()
    sel=0
    tab={   {img="Planet Cute:Character Boy",
               x=math.random(WIDTH),y=math.random(HEIGHT)},
            {img="Planet Cute:Character Horn Girl",
                x=math.random(WIDTH),y=math.random(HEIGHT)},
            {img="Planet Cute:Character Princess Girl",
                x=math.random(WIDTH),y=math.random(HEIGHT)} }
end

function draw()
    background(40, 40, 50)
    for a,b in pairs(tab) do
        sprite(b.img,b.x,b.y)
    end
end

function touched(t)
    if t.state==BEGAN then
        for a,b in pairs(tab) do
            if t.x>b.x-50 and t.x<b.x+50 and t.y>b.y-50 and t.y<b.y+50 then
                sel=a
            end
        end
    end
    if t.state==MOVING and sel>0 then
        tab[sel].x=t.x
        tab[sel].y=t.y
    end
    if t.state==ENDED then
        sel=0
    end
end