Corona Simulator Problem?

I am currently doing a tutorial on Corona Labs and the tutorial is the creating of a game. On the tutorial when the simulator is ran it covers the whole screen of the iPhone. I have the same code and for some reason it only shows the top left corner of the iPhone. Any help?

What version of Corona SDK are you using?

What is the URL to the tutorial?

I suspect the issue is the tutorial was written for an older version of Corona SDK.  Look at: http://docs.coronalabs.com/guide/graphics/migration.html to try and solve your problems.  

Rob

http://coronalabs.com/resources/tutorials/sample-code/

It’s the Game Development Crash Course at the bottom. Watch the second video.

I just downloaded Corona today so I assume its the most updated version. 

Many of Jay’s tutorials pre-dates Graphics 2.0.  I know he’s been working to update them. I can’t watch the video right now, but let me ask you a question.  Are you doing a:

background = display.newRect( 0, 0 , somewidth, someheight)

?  if so, in graphics 1.0, the first two parameters to display.newRect() represented the top left corner.  In graphics 2.0, they represent the center of the rectangle, which would cause it to shift to the top left.   There are four ways to fix this.

1.  In your config.lua file add this line:

graphicsCompatibility = 1

at the same block where you set the width and height.  This will cause our routines to default to their old behavior.

  1. Change any display.*() API call that takes an X, Y as the first two parameters to represent the center of the object.  Since I suspect you want to center this rectangle:

background = display.newRect( display.contentCenterX, display.contentCenterY, whateverWidth, whateverHeight)

3.  Use anchor points to tell Corona that you want to align on the top right corner:

background = display.newRect( 0, 0 , somewidth, someheight)

background.anchorX = 0

background.anchorY = 0

  1. Manually position it after you create it.

background = display.newRect( 0, 0 , somewidth, someheight)

background.x = display.contentCenterX

background.y = display.contentCenterY

For #1, I don’t know how many future versions will maintain that compatibility.  It should stay for a while, but we will have to cull it at some point.  But you should be able to use the rest of Jay’s tutorials without issue.

For #2, it makes for some long lines of code.

For #3, anchor points may be a bit too much for a new person to figure out.

For #4, this is what I do.  When I first learned Corona SDK it was frustrating to try and remember which things were top left aligned and which were center aligned.  The day we made everything center aligned, the world became a happier place, except for the tutorial and book authors who had it the old way.

While you are doing Jay’s tutorials, I would go with #1, but learning #2 or #4 will be your long term best practice.

Rob

Definitely. Graphics 2.0 has many excellent features, from the viewpoint of learning the tutorials not a huge amount has changed. 

The other main change, OTOMH, is that in 1.0 graphics colours are 0-255 - so 100% Red 50% Green 0% Blue would be

someObject:setFillColor(255,127,0)

because 127 is (nearly) 50% of 255 whereas now it’s a 0-1 range

someObject:setFillColor(1,0.5,0)

So watch for this in new code - whereas colour 1,1,1 is now white, on v1 compatibility it will be a very dark grey, indistinguishable visibly from black.

Ah, Color. Or as we spell it (properly :wink: “Colour”. If I had a pound for every time I’ve had a syntax error in something caused because of this I’d be very very rich.

And the method for setting the anchors (the point of an object that it rotates around or is used to position it) has changed as well.

What version of Corona SDK are you using?

What is the URL to the tutorial?

I suspect the issue is the tutorial was written for an older version of Corona SDK.  Look at: http://docs.coronalabs.com/guide/graphics/migration.html to try and solve your problems.  

Rob

http://coronalabs.com/resources/tutorials/sample-code/

It’s the Game Development Crash Course at the bottom. Watch the second video.

I just downloaded Corona today so I assume its the most updated version. 

Many of Jay’s tutorials pre-dates Graphics 2.0.  I know he’s been working to update them. I can’t watch the video right now, but let me ask you a question.  Are you doing a:

background = display.newRect( 0, 0 , somewidth, someheight)

?  if so, in graphics 1.0, the first two parameters to display.newRect() represented the top left corner.  In graphics 2.0, they represent the center of the rectangle, which would cause it to shift to the top left.   There are four ways to fix this.

1.  In your config.lua file add this line:

graphicsCompatibility = 1

at the same block where you set the width and height.  This will cause our routines to default to their old behavior.

  1. Change any display.*() API call that takes an X, Y as the first two parameters to represent the center of the object.  Since I suspect you want to center this rectangle:

background = display.newRect( display.contentCenterX, display.contentCenterY, whateverWidth, whateverHeight)

3.  Use anchor points to tell Corona that you want to align on the top right corner:

background = display.newRect( 0, 0 , somewidth, someheight)

background.anchorX = 0

background.anchorY = 0

  1. Manually position it after you create it.

background = display.newRect( 0, 0 , somewidth, someheight)

background.x = display.contentCenterX

background.y = display.contentCenterY

For #1, I don’t know how many future versions will maintain that compatibility.  It should stay for a while, but we will have to cull it at some point.  But you should be able to use the rest of Jay’s tutorials without issue.

For #2, it makes for some long lines of code.

For #3, anchor points may be a bit too much for a new person to figure out.

For #4, this is what I do.  When I first learned Corona SDK it was frustrating to try and remember which things were top left aligned and which were center aligned.  The day we made everything center aligned, the world became a happier place, except for the tutorial and book authors who had it the old way.

While you are doing Jay’s tutorials, I would go with #1, but learning #2 or #4 will be your long term best practice.

Rob

Definitely. Graphics 2.0 has many excellent features, from the viewpoint of learning the tutorials not a huge amount has changed. 

The other main change, OTOMH, is that in 1.0 graphics colours are 0-255 - so 100% Red 50% Green 0% Blue would be

someObject:setFillColor(255,127,0)

because 127 is (nearly) 50% of 255 whereas now it’s a 0-1 range

someObject:setFillColor(1,0.5,0)

So watch for this in new code - whereas colour 1,1,1 is now white, on v1 compatibility it will be a very dark grey, indistinguishable visibly from black.

Ah, Color. Or as we spell it (properly :wink: “Colour”. If I had a pound for every time I’ve had a syntax error in something caused because of this I’d be very very rich.

And the method for setting the anchors (the point of an object that it rotates around or is used to position it) has changed as well.