Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Odd behaviour when recording

edited September 2012 in Bugs Posts: 892

I'm playing about with a lemmings type game and when I tried to record the video I get strange effects. While it records, the them image is not cleared between frames so I get a trail effect, though when viewing back the video is fine ( and also reverts to normal when I stop recording). Secondly I have implemented destructible landscape but when recording, it shifts the location of the affected area. Thirdly,when the explosions appear the made with codea logo disappears. Has anyone else experienced this?

Comments

  • JohnJohn Admin Mod
    Posts: 643

    @West

    Are you using setContext() while recording? I think there could be an issue with this. I'll try to figure out whats happening. Looks great so far by the way.

  • Posts: 892

    Yes I am. The background is an image which I'm using to update. Here's a snippet from the update

                elseif self.state==shrug then
                    -- bang
                sprite("Dropbox:Bang",self.x,self.y)   
                setContext(bgimg)
                sprite("Dropbox:Hole",self.x,self.y)
                setContext()
                self.state=angel
                self.trans=0 
                end
    

    bgimg is used as a texture on a mesh

  • edited September 2012 Posts: 123

    Cool, Lemmings in Codea :-)

    I cant contribute to your question, but I'am interested how fast this works for you. Because I have tried to draw trails of a snake like game in a background image and render that, but my framerate drops below 3 fps. It seems to work for you so I wonder what the difference is. I render the bgimage with the sprite() function, but I don't think thats the point, as it only drops when I use setContext.

    The other discussion: http://www.twolivesleft.com/Codea/Talk/discussion/1622/snake-by-lines

  • Posts: 892

    The background is an image which is mapped to a mesh texture. I only update via setContext very occasionally -when I want to create the blast crater. The lemming type men are all rectangles on a single mesh which is very quick. The explosion currently is a sprite but I'll convert to a mesh too in time.
    It all runs pretty fast. Will take a look at the thread to see if I can offer an alternative for the snake

  • Thanks. My current solution is to draw the trail in retained mode and also draw the trail in a background array with one fourth of the display resolution for collision checking. well, it works, but I dont like the retained mode when I have to display other things than the trails at the same time. also, it has a bug in fullscreen on ipad 3.

    I could post a slow version if you want to look at it.

  • Posts: 892

    Yes, I'll take a look when I get the chance.

  • Posts: 892

    @John

    Here is a demo of the issue with associated code

    -- BackgroundTest
    displayMode(FULLSCREEN)
    -- Use this function to perform your initial setup
    function setup()
        touches={}
        globalx=0
        globaly=0
        scroll=-1
        vscroll=-1
        cratesize=50
        bgw=60
        bgh=60
        tilew=bgw
        tileh=bgh
        bg={}
        bgimg={}
        numMesh=30
        numMeshVert=8
        crater=image(50,50)
        setContext(crater)
        fill(0,0,0)
        ellipse(25,25,50)
        setContext()
        
        for v=1,numMeshVert do
            bg[v]={}
            bgimg[v]={}
            for i=1,numMesh do
                bg[v][i]=mesh() 
                bgimg[v][i]=image(bgw,bgh)
                bg[v][i].texture=bgimg[v][i]
                setContext(bgimg[v][i])
                background(0,0,0)
            if (math.random(3)==1 or v<3 )and v~=numMeshVert then
                sprite("Cargo Bot:Crate Yellow 2",tilew/2,tileh/2,tilew,tileh)
                end
                setContext()
            end
        end
    
    end
    
    function touched(touch)
        if touch.state == ENDED then
            touches[touch.id] = nil
        else
            touches[touch.id] = touch
        end
    end
    -- This function gets called once every frame
    function draw()
        -- This sets a dark background color 
    
        
        background(0,0,0)    
        for v=1,numMeshVert do
            for i=1,numMesh do
                bg[v][i]:clear()
                --only draw those that appear on the screen will speed it up
                if i*tilew+globalx>0 and i*tilew+globalx<1024+tilew then
                    local bgid=bg[v][i]:addRect(globalx+((i-1)*tilew+tilew/2),((v-1)*tileh+tileh/2),tilew,tileh)
                    bg[v][i]:setRectTex(bgid,0,0,1,1)
                    bg[v][i]:draw()
                end
           --     text(i*tilew,600,600)
            end
        end
        if tilew*numMesh>WIDTH then
            globalx = globalx + scroll
            if globalx>0 or globalx<-(numMesh)*tilew+WIDTH then
                scroll=scroll*-1
            end
        end
        
        for k,touch in pairs(touches) do
            for v=1,numMeshVert do
                for i=1,numMesh do            
                    if touch.x<i*tilew+globalx and touch.x>=(i-1)*tilew+globalx and touch.y<v*tileh+globaly and touch.y>=(v-1)*tileh+globaly then
                        -- centre of the mesh
                        setContext(bgimg[v][i])
                        sprite(crater,(-1*(i-1)*tilew)+touch.x-globalx,(-1*(v-1)*tileh)+touch.y-globaly,cratesize,cratesize)
                        setContext()  
                    end
                    if touch.x>i*tilew+globalx-cratesize/2 and touch.x<i*tilew+globalx and touch.y<v*tileh+globaly and touch.y>=(v-1)*tileh+globaly and i<numMesh then
                        --leaks into mesh to the right
                        setContext(bgimg[v][i+1])
                        sprite(crater,-i*tilew-globalx+touch.x,(-1*(v-1)*tileh)+touch.y-globaly,cratesize,cratesize)
                        setContext()
                    end 
                    if touch.x>(i-1)*tilew+globalx and touch.x<(i-1)*tilew+globalx+cratesize/2 and touch.y<v*tileh+globaly and touch.y>=(v-1)*tileh+globaly and i>1 then
                        --leak into mesh to the left
                        setContext(bgimg[v][i-1])
                        sprite(crater,-(i-2)*tilew+touch.x-globalx,(-1*(v-1)*tileh)+touch.y-globaly,cratesize,cratesize)
                        setContext()  
                    end
                    if touch.x<i*tilew+globalx and touch.x>=(i-1)*tilew+globalx and touch.y>(v-1)*tileh+globaly and touch.y<(v-1)*tileh+globaly+cratesize/2 and v>1 then
                        --leak into mesh below
                        setContext(bgimg[v-1][i])
                        sprite(crater,(-1*(i-1)*tilew)+touch.x-globalx,(-1*(v-2)*tileh)+touch.y-globaly,cratesize,cratesize)
                        setContext()  
                    end
                   if touch.x<i*tilew+globalx and touch.x>=(i-1)*tilew+globalx and touch.y>v*tileh+globaly-cratesize/2 and touch.y<v*tileh+globaly and v<numMeshVert then
                        --leak into mesh above
                        setContext(bgimg[v+1][i])
                        sprite(crater,(-1*(i-1)*tilew)+touch.x-globalx,(-1*(v)*tileh)+touch.y-globaly,cratesize,cratesize)
                        setContext()  
                    end  
                    if touch.x>i*tilew+globalx-cratesize/2 and touch.x<i*tilew+globalx and touch.y>v*tileh+globaly-cratesize/2 and touch.y<v*tileh+globaly and i<numMesh and v<numMeshVert then
                        --leaks into mesh up and to the right
                        setContext(bgimg[v+1][i+1])
                        sprite(crater,-i*tilew-globalx+touch.x,(-1*(v)*tileh)+touch.y-globaly,cratesize,cratesize)
                        setContext()
                    end 
                      if touch.x>i*tilew+globalx-cratesize/2 and touch.x<i*tilew+globalx and touch.y>(v-1)*tileh+globaly and touch.y<(v-1)*tileh+globaly+cratesize/2 and i<numMesh and v>1 then
                        --leaks into mesh below and to the right
                        setContext(bgimg[v-1][i+1])
                        sprite(crater,-i*tilew-globalx+touch.x,(-1*(v-2)*tileh)+touch.y-globaly,cratesize,cratesize)
                        setContext()
                    end         
                    if touch.x>(i-1)*tilew+globalx and touch.x<(i-1)*tilew+globalx+cratesize/2 and touch.y>v*tileh+globaly-cratesize/2 and touch.y<v*tileh+globaly and i>1 and v<numMeshVert then
                        --leaks into mesh up and to the left
                        setContext(bgimg[v+1][i-1])
                        sprite(crater,-(i-2)*tilew-globalx+touch.x,(-1*(v)*tileh)+touch.y-globaly,cratesize,cratesize)
                        setContext()
                    end         
                        if touch.x>(i-1)*tilew+globalx and touch.x<(i-1)*tilew+globalx+cratesize/2 and touch.y>(v-1)*tileh+globaly and touch.y<(v-1)*tileh+globaly+cratesize/2 and i>1 and v>1 then
                        --leaks into mesh down and to the left
                        setContext(bgimg[v-1][i-1])
                        sprite(crater,-(i-2)*tilew-globalx+touch.x,(-1*(v-2)*tileh)+touch.y-globaly,cratesize,cratesize)
                        setContext()
                    end         
                end
           end 
        sprite("Cargo Bot:Star Filled",touch.x,touch.y,cratesize,cratesize)
        end  
    end
    
  • JohnJohn Admin Mod
    Posts: 643

    Hi @West

    We've encountered that issue too. Are you using an iPad 3? It has to do with the way video recording changes the screen resolution. We are working to fix this problem in the next release.

  • Hi @West, unfortunatly, i don't have the answer for your problem, just wanted to tell you that your Slide Scroller video is awsome!

  • Posts: 892

    Hi @John, yes it's an iPad 3

    @yelnats Thanks -another work in progress, but I keep getting distracted by new ideas! I wonder if I'll actually ever finish a game

  • JohnJohn Admin Mod
    Posts: 643

    Hi @West, I've fixed this bug, you can expect it in our next major release (1.5)

Sign In or Register to comment.