delete me please

Hey there,

Thank for responding.

>What version of Corona are you using? 

CoronaSDK-2013.1202

>What version were you using when it worked last?

CoronaSDK-2013.1202

> What code is at line 106?

p.x = x

You can see in post #2 the modifications that were suggested to me. And they were working at the time with the same version. Unsure what happened, the file hasn’t been changed since.

Hey there, okay I’ve figured that out! I need help with one last thing if you guys are willing!

Below I put in an image (image2.png) to represent an object labeled both “food” and “enemy” in the fat freddy template. What I would like to do, however, is have a separate image for food and enemy.

local collisionFilter = { categoryBits = 4, maskBits = 2 } – collides with player only

local body = { filter=collisionFilter, isSensor=true }

    if “food” == objectType or “enemy” == objectType then

        object = display.newImage(“image2.png”,  startX, startY, 1, 1 )

        object.sizeXY = 1

    end

So I tried this:

if “enemy” == objectType then

        object = display.newImage(“image4.png”,  startX, startY, 1, 1 )

        object.sizeXY = 1

    end

    if “reward” == objectType or “penalty” == objectType then

        object = display.newImage(“image3.jpg”, startX, startY, 1, 1 )

        object.sizeXY = 1

    end

However get this error:

fatfreddyerror.png

This is the last thing I need help with and then I’ll be good to go :slight_smile:

What is line 328?

Are there additional messages in your console log?

I see one image is a .png the other is a .jpg.  Is that right?

Hey!

 

> What is line 328?

 

According to http://textmechanic.com/Number-Each-Line.html it is “object.objectType = objectType” Here is the line in context:

 

local collisionFilter = { categoryBits = 4, maskBits = 2 }

local body = { filter=collisionFilter, isSensor=true }

    if “enemy” == objectType then

        object = display.newImage(“image4.png”,  startX, startY, 1, 1 )

        object.sizeXY = 1

    end

    if “reward” == objectType or “penalty” == objectType then

        object = display.newImage(“image3.jpg”, startX, startY, 1, 1 )

        object.sizeXY = 1

    end

    

    if “reward” == objectType or “penalty” == objectType then

        object = display.newImage(“image3.jpg”, startX, startY, 1, 1 )

        object.sizeXY = 1

    end

local objectAlpha

object.objectType = objectType

object.xVelocity = xVelocity

object.yVelocity = yVelocity

physics.addBody ( object, body )

object.isFixedRotation = true

table.insert ( objects,  object )

end–}}}

 

> Are there additional messages in your console log?

 

The Corona Simulator Output has the same error messages as the Corona Runtime Error.

 

> I see one image is a .png the other is a .jpg.  Is that right?

 

Yep!

 

Thank you.

Okay that makes sense.  Because you are using “if” statements independently instead of an if-then-else method, it’s possible that your code can get to that line and have never created object.

It’s possible that objectType is never reward or penalty.  Perhaps adding some prints in there to see what your values are will let you know what values you are really getting.

Adding some prints? The original code had one shape for the same “food” & “enemy” labels:

local collisionFilter = { categoryBits = 4, maskBits = 2 } – collides with player only

    local body = { filter=collisionFilter, isSensor=true }

    if “food” == objectType or “enemy” == objectType then

         object = display.newRect (  startX, startY, sizeXY, sizeXY )

        object.sizeXY = sizeXY

    end

 

The only thing that was different was the color fill (the enemy was a certain colored square, and the food was a different colored square.) I didn’t want Corona to draw images, yet use my own I created in GIMP, so I changed the code to this:

 

local collisionFilter = { categoryBits = 4, maskBits = 2 } – collides with player only

local body = { filter=collisionFilter, isSensor=true }

    if “food” == objectType or “enemy” == objectType then

        object = display.newImage (“image2.png”,  startX, startY, 1, 1 )

        object.sizeXY = 1

    end

 

The only issue is, I want a different image for the food object and a different image for the enemy object. Is that not something I can do?

Yes, “add prints”, things like:

print (“objectType is”, objectType)

Then look in the console log/terminal/cmd window and see what gets printed out.  This tutorial might be of use to you: http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Any update on this? :confused: Did something change with how Corona works?

Well the error is telling me that the object p is nil.  If p is coming from that display.newImageRect() perhaps the image isn’t there, invalid, or for some reason.  Have you looked at your console log to see if there are any more messages besides the one that pops up?

Read this if you need to learn how to read the console log: http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

I read the article you’ve posted. I guess I am missing something. Using the template, I want one image for food and another one for enemy.

It seems you’re asking a different question.  I’m trying to help you figure out the error you are getting.  The way your code is written it will fail if objectType is not “penalty”, “enemy” or “reward”.  If it’s something else, then your if statements will not evaluate to true and you will get this p object being nil.  I want you to print out the value of the objectType variable and make sure you are getting the values you expect in there.

Rob

Hey there, okay I’ve figured that out! I need help with one last thing if you guys are willing!

Below I put in an image (image2.png) to represent an object labeled both “food” and “enemy” in the fat freddy template. What I would like to do, however, is have a separate image for food and enemy.

local collisionFilter = { categoryBits = 4, maskBits = 2 } – collides with player only

local body = { filter=collisionFilter, isSensor=true }

    if “food” == objectType or “enemy” == objectType then

        object = display.newImage(“image2.png”,  startX, startY, 1, 1 )

        object.sizeXY = 1

    end

So I tried this:

if “enemy” == objectType then

        object = display.newImage(“image4.png”,  startX, startY, 1, 1 )

        object.sizeXY = 1

    end

    if “reward” == objectType or “penalty” == objectType then

        object = display.newImage(“image3.jpg”, startX, startY, 1, 1 )

        object.sizeXY = 1

    end

However get this error:

fatfreddyerror.png

This is the last thing I need help with and then I’ll be good to go :slight_smile:

What is line 328?

Are there additional messages in your console log?

I see one image is a .png the other is a .jpg.  Is that right?

Hey!

 

> What is line 328?

 

According to http://textmechanic.com/Number-Each-Line.html it is “object.objectType = objectType” Here is the line in context:

 

local collisionFilter = { categoryBits = 4, maskBits = 2 }

local body = { filter=collisionFilter, isSensor=true }

    if “enemy” == objectType then

        object = display.newImage(“image4.png”,  startX, startY, 1, 1 )

        object.sizeXY = 1

    end

    if “reward” == objectType or “penalty” == objectType then

        object = display.newImage(“image3.jpg”, startX, startY, 1, 1 )

        object.sizeXY = 1

    end

    

    if “reward” == objectType or “penalty” == objectType then

        object = display.newImage(“image3.jpg”, startX, startY, 1, 1 )

        object.sizeXY = 1

    end

local objectAlpha

object.objectType = objectType

object.xVelocity = xVelocity

object.yVelocity = yVelocity

physics.addBody ( object, body )

object.isFixedRotation = true

table.insert ( objects,  object )

end–}}}

 

> Are there additional messages in your console log?

 

The Corona Simulator Output has the same error messages as the Corona Runtime Error.

 

> I see one image is a .png the other is a .jpg.  Is that right?

 

Yep!

 

Thank you.

Okay that makes sense.  Because you are using “if” statements independently instead of an if-then-else method, it’s possible that your code can get to that line and have never created object.

It’s possible that objectType is never reward or penalty.  Perhaps adding some prints in there to see what your values are will let you know what values you are really getting.

Adding some prints? The original code had one shape for the same “food” & “enemy” labels:

local collisionFilter = { categoryBits = 4, maskBits = 2 } – collides with player only

    local body = { filter=collisionFilter, isSensor=true }

    if “food” == objectType or “enemy” == objectType then

         object = display.newRect (  startX, startY, sizeXY, sizeXY )

        object.sizeXY = sizeXY

    end

 

The only thing that was different was the color fill (the enemy was a certain colored square, and the food was a different colored square.) I didn’t want Corona to draw images, yet use my own I created in GIMP, so I changed the code to this:

 

local collisionFilter = { categoryBits = 4, maskBits = 2 } – collides with player only

local body = { filter=collisionFilter, isSensor=true }

    if “food” == objectType or “enemy” == objectType then

        object = display.newImage (“image2.png”,  startX, startY, 1, 1 )

        object.sizeXY = 1

    end

 

The only issue is, I want a different image for the food object and a different image for the enemy object. Is that not something I can do?

Yes, “add prints”, things like:

print (“objectType is”, objectType)

Then look in the console log/terminal/cmd window and see what gets printed out.  This tutorial might be of use to you: http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

I read the article you’ve posted. I guess I am missing something. Using the template, I want one image for food and another one for enemy.

It seems you’re asking a different question.  I’m trying to help you figure out the error you are getting.  The way your code is written it will fail if objectType is not “penalty”, “enemy” or “reward”.  If it’s something else, then your if statements will not evaluate to true and you will get this p object being nil.  I want you to print out the value of the objectType variable and make sure you are getting the values you expect in there.

Rob