Codea bugs and crashes

I just spent 2 hours in the car with Codea to find a lot of bugs and crashes. Here are some of them:

  1. It seems that the user acceleration x and y are reversed. It’s in the right orientation, but you can check that out.
  2. Some help file don’t wrap the text (like physics.iterations) and none wrap code, so please allow scrolling to the side.
  3. For some reason, I stacked about 20 boxes right on top of each other, and even when they are placed exactly on top of each other and when dropped, they fall. The gravity is the default one and each body has the same characteristics. And it’s not random because they always end up the same way when they stop moving.
  4. Crash with this code:

function setup()
   frogLive = frog()
   frogDead = deadFrog()
   pfrogx = 100
   pfrogy = 100
   frogx = 100
   frogy = 100
   frogw, frogh = spriteSize(frogLive)
   froglives = 0
   frogBody = physics.body(CIRCLE,frogw)

-- This function gets called once every frame
function draw()

   background(0, 0, 0, 255)


   fill(173, 173, 173, 255)

   stroke(255, 251, 0, 255)


   -- Do your drawing here


function drawFrog()
   pfrogx = frogx
   pfrogy = frogy
   frogx = frogx + Gravity.x*10
   frogy = frogy + Gravity.y*10
   if frogx >= WIDTH or frogx <= 0 then
       frogx = pfrogx
   if frogy >= HEIGHT or frogy <= 0 then
       frogy = pfrogy

function drawRoad()
   rect(0,HEIGHT - HEIGHT/7*6,WIDTH,HEIGHT/7*5)

function drawLines()
   for i = 0, WIDTH/50 do
       sline = i * 50
       line(sline, CurrentTouch.y,sline+25,CurrentTouch.y)

It’s this that crashes it:frogw, frogh = spriteSize(frogLive). Help? I’d give you the crash log, but it’s too long.
As you can see, I’m coding Frogger.
5. “y” is listed twice under mesh.addRect() and there is duplicate text in some other files.
6. There were a few other bugs I’ll identify and list later.
But with all this time, I came to love Codea even more (if that’s even possible).

spriteSize takes a string of a sprite pack name. You can’t give it an image — to get an image size use image.width / image.height.

Oh. Thanks.

That said, spriteSize shouldn’t crash with incorrect parameters. We’ll fix it.

Thanks for reporting the other bugs.

I raised a bug report against the spriteSize issue a few days ago.

IMHO, if passed an image it should return image.width, image.height. Sprite names and images are interchangeable elsewhere (e.g. as a parameter to the sprite(…) function) and therefore should be everywhere, I think.

I’ve had to write ugly conditional code to work around the issue.

I hit the same crash the other day, too :slight_smile:
@Nat’s suggestion sounds pretty good to me.

I agree, @Nat. That is an elegant solution. We’ll change it.


This is fixed in the next update (spriteSize)