Sprite Bug

I had a sprite set to a certain image, and the I changed it but it was still drawing the previous image.

Please be more specific. What do you mean you had it set, what do you mean you changed it, and what do you mean it was still drawing the previous image? Any chance of seeing your code?

I told it to draw a robot. Then I changed it to draw a ball, but it was still drawing the robot.

Now it’s working, but that was what was happening.

Code?

Edit: Oh.

@EpicPotato - please post code.

99% of the time, it’s a bug in the code, not in Codea.

And now it won’t draw the sprite at the right size.

Code, please?

But now it’s working. It seems to be a problem where Codea is not saving very quickly.

Please post the code, Codea should save the code instantly once you press run.

--# Main

function setup() 
    parameter.watch(PlayerY) 
    displayMode(FULLSCREEN_NO_BUTTONS)
    supportedOrientations(LANDSCAPE_ANY) 
    floor1 = physics.body(EDGE,vec2(-500,HEIGHT/2 - 200),vec2(1000,HEIGHT/2 - 200)) 
    floor2 = physics.body(EDGE,vec2(500,HEIGHT - 200),vec2(1000,HEIGHT - 200)) 
    Player = physics.body(CIRCLE,20)
    
    -- moved the following line from draw
    Player.x = WIDTH/2 Player.y = HEIGHT/2 floor1.x = 500
    
    physics.gravity(0,-400)     -- changed
    parameter.watch("PlayerX") 
    parameter.watch("PlayerY") 
     parameter.watch("Floor1Y") 
    floor1.linearVelocity = vec2(-200,0) 
    Scene = 1 
    scrollTitleScreen = 0 
    xVel = 0 
    yVel = 0 
    physics.friction = .9
end

function draw()
    --Draws the appropritate stagese
    --Scenes:
    --1 = Title Screen
    --2 = Gamemode Select
    --3 = Stage select
    --4 = Ingame
    scene = Scene
    PlayerX = Player.x
    PlayerY = Player.y -234
    Floor1Y = floor1.y
    textMode(CENTER)
    Player.restution = 1
    floor1.restution = 0.4
    
    -- moved this line to setup
    --Player.x = WIDTH/2 Player.y = HEIGHT/2 floor1.x = 500

    if Scene == 1 then 
        strokeWidth(5) 
        background(0, 255, 251, 255) 
        font("Copperplate-Bold") 
        fill(0, 0, 0, 255) 
        fontSize(87) 
        text("THE PROTO PROGRAM",WIDTH/2,HEIGHT -78) 
        rectMode(CENTER) 
        fill(0, 255, 251, 255) 
        stroke(0, 0, 0, 255) 
        rect(WIDTH/2,HEIGHT/2,250,126) 
        fill(0, 0, 0, 255) 
        fontSize(60) text("PLAY",WIDTH/2,HEIGHT/2)
    elseif Scene == 2 then
        strokeWidth(5)
        fontSize(84)
        stroke(0, 0, 0, 255)
        fill(51,51,51,255)
        background(0,255,251,255)
        rectMode(CENTER)    
        fill(0, 0, 0, 255)
        text("CHOOSE A GAMEMODE",WIDTH/2,HEIGHT -78)
        fill(0, 255, 251, 255)
        rect(WIDTH/2,HEIGHT/2,250,126) 
        fontSize(27)
        fill(0,0,0,250)
        text("DEATHMATCH",WIDTH/2,HEIGHT/2)
        rectMode(CORNER)
        fill(0, 255, 251, 255)
        rect(-3,-3,100,50)
        rectMode(CENTER)
        textMode(CORNER)
        fontSize(25)
        fill(0, 0, 0, 255)
        text("BACK",9,10)
   elseif Scene == 3 then
        background(0,255,251,255)
        strokeWidth(5)
        fontSize(84)
        stroke(0, 0, 0, 255)
        background(0,255,251,255)
        rectMode(CENTER)
        fill(0, 0, 0, 255)
        text("CHOOSE A STAGE",WIDTH/2,HEIGHT -78)
        fill(0, 255, 251, 255)
        rect(WIDTH/2,HEIGHT/2,250,126) 
        fontSize(49)
        fill(0,0,0,250)
        text("METRO",WIDTH/2,HEIGHT/2)
        rectMode(CORNER)
        fill(0, 255, 251, 255)
        rect(-3,-3,100,50)
        rectMode(CENTER)
        textMode(CORNER)
        fontSize(25)
        fill(0, 0, 0, 255)
        text("BACK",9,10)
        
   elseif Scene == 4 then
        rectMode(CENTER)
        stroke(0, 0, 0, 255)
        fill(127, 127, 127, 255)
        strokeWidth(5)
        fontSize(84)
        stroke(0, 0, 0, 255)
        background(35, 47, 47, 255)
        rectMode(CENTER)
        fill(0, 0, 0, 255)
         rect(floor1.x,220,1200,90)
        rect(floor2.x + 1080,570,1200,20)
        fontSize(49)
        fill(0,0,0,250)
        rectMode(CORNER)
        fill(0, 255, 251, 255)
        rect(-3,-3,200,100)
        rectMode(CENTER)
        textMode(CORNER)
        fontSize(55)
        fill(0, 0, 0, 255)
        text("LEFT",9,10) 
        rectMode(CORNER)
        fill(0, 255, 251, 255)
        stroke(0, 0, 0, 255)
        rect(197,-3,200,100)
        rectMode(CENTER)
        textMode(CORNER)
        fontSize(55)
        fill(0, 0, 0, 255)
        text("RIGHT",209,10) 
        rectMode(CENTER)
                rectMode(CORNER)
        fill(0, 255, 251, 255)
        stroke(0, 0, 0, 255)
        rect(95,97,200,100)
        rectMode(CENTER)
        textMode(CORNER)
        fontSize(55)
        fill(0, 0, 0, 255)
        text("RIGHT",209,10) 
        rectMode(CENTER)
        
        sprite("Documents:Cyborg",Player.x,Player.y,73,90)
if Scene == 5 then
         rectMode(CENTER)
        stroke(0, 0, 0, 255)
        fill(127, 127, 127, 255)
        strokeWidth(5)
        fontSize(84)
        stroke(0, 0, 0, 255)
        background(35, 47, 47, 255)
        rectMode(CENTER)
        fill(0, 0, 0, 255)
         rect(floor1.x,200,1200,90)
        fontSize(49)
        fill(0,0,0,250)
        rectMode(CORNER)
        fill(0, 255, 251, 255)
        rect(-3,-3,200,100)
        rectMode(CENTER)
        textMode(CORNER)
        fontSize(55)
        fill(0, 0, 0, 255)
        text("LEFT",9,10) 
        rectMode(CORNER)
        fill(0, 255, 251, 255)
        stroke(0, 0, 0, 255)
        rect(197,-3,200,100)
        rectMode(CENTER)
        textMode(CORNER)
        fontSize(55)
        fill(0, 0, 0, 255)
        text("RIGHT",209,10) 
        rectMode(CENTER)
                rectMode(CORNER)
        fill(0, 255, 251, 255)
        stroke(0, 0, 0, 255)
        rect(95,97,200,100)
        rectMode(CENTER)
        textMode(CORNER)
        fontSize(55)
        fill(0, 0, 0, 255)
        text("RIGHT",209,10) 
        rectMode(CENTER)
        
        sprite("Documents:Cyborg",Player.x,Player.y,20,1000)   
        rect(WIDTH/2,HEIGHT/2,500,400)
end
end
end


--Buttons 
--DeathMatch button 
function touched(touch) 
    if touch.state == ENDED and touch.x > WIDTH/2 - 125 and 
            touch.x < WIDTH /2 + 125 and touch.y < HEIGHT/2+63 and 
            touch.y > HEIGHT/2- 63 and Scene == 2 then
        Scene = 3
        sound(SOUND_BLIT, 16900)
        Player.x = 500
        Player.y = 500
    end 
    --Play button 
    if touch.state == ENDED and touch.x > WIDTH/2 - 125 and 
            touch.x < WIDTH /2 + 125 and touch.y < HEIGHT/2+63 and 
            touch.y > HEIGHT/2- 63 and Scene == 1 then
        Scene = 2
        sound(SOUND_BLIT, 16900)
    end
    --Metro stage button 
    if touch.state == ENDED and touch.x > WIDTH/2 - 125 and 
        touch.x < WIDTH /2 + 125 and touch.y < HEIGHT/2+63 and 
            touch.y > HEIGHT/2- 63 and Scene == 3 then
        Scene = 4
        sound(SOUND_BLIT, 16900)
        floor1.x = 500
        floor1.y = 100
    end
    --Back button (title screen) 
    if touch.state == ENDED and touch.x > 0 and touch.x < 100 and 
        touch.y < 100 and touch.y > 0 and Scene ~= 1 and Scene ~= 4 then
        Scene = Scene -1
        sound(SOUND_BLIT, 16900)
    end  
    --Ingame buttons
    --Left button
    if Scene == 4 then
        if touch.x > 0 and touch.x < 200 and 
        touch.y < 100 and touch.y > 0 then
            if touch.state == BEGAN or touch.state == MOVING then
                xVel = -100
              yVel = 0
                updatePlayerVel()
            end
        elseif touch.state == ENDED then
            xVel = 0
            
            updatePlayerVel()
        end
        --Right button
        if touch.x > 200 and touch.x < 400 and 
        touch.y < 100 and touch.y > 0 then
            if touch.state == BEGAN or touch.state == MOVING then
                xVel = 100
                yVel = 0
                
                updatePlayerVel()
            end
        elseif touch.state == ENDED then
            xVel = 0
            updatePlayerVel()
        end
        --Jump button
       
       if touch.x > 95 and touch.x < 295 and 
        touch.y < 200 and touch.y > 100 then
            if touch.state == BEGAN then
                yVel = 300
                
              
            updatePlayerVel()
        end
    end
end 
end
function updatePlayerVel() 
    Player.linearVelocity = vec2(xVel,yVel) 
    end

Only put the three ~ at the very top and very bottom of your code…

What three

The ~~~. Put them at only the very top and very bottom of your code for proper code formatting.

There you go.

It doesn’t draw any sprites for me, just black rectangles.

Oh, that’s because the sprite is my Dropbox file. Just change both sprites to one of your images and set the width to 73, the height to 90.

It’s properly sized for me. If you have transparent pixels around the edges, it might render those, though, and appear as if it’s smaller than it really is.

Yes, it’s right for me too, but its like I set the height to 1000. But when I play the program the height is still 50 or something. Then I exit the program editor and come back in and it says the height is 50. Then when I change it, it works. Codea isn’t saving properly.

1000 resizes it for me. Can you explain exactly what you did, and every button you pressed when it wasn’t saving?