Corona sdk beginners guide & Sprite size for item catching game on ipad

Awhile back I bought the ebook version of corona sdk beginners guide. In the chapter covering Egg Drop, it appears that the game is made for a iphone.

[lua]local characterSheet = sprite.newSpriteSheet
( “charSprite.png”,128, 128 )
local spriteSet = sprite.newSpriteSet(characterSheet, 1, 4)
sprite.add(spriteSet, “move”, 1, 4, 400, 0 )
charObject = sprite.newSprite( spriteSet )
charObject:prepare(“move”)
charObject:play()
charObject.x = 240; charObject.y = 250
physics.addBody( charObject, “static”, { density=1.0,
bounce=0.4, friction=0.15, shape=panShape } )
charObject.rotation = 0
charObject.isHit = false
charObject.myName = “character”[/lua]

If I’m not mistaken doesn’t sound right for moving a character plus collision. Also, is there a revision for the ebook version? Because when I downloaded the source, the lua code looks different compared to the book and chapter 7 doesn’t have a main.lua file. [import]uid: 128294 topic_id: 27388 reply_id: 327388[/import]

You would want to contact the author; we haven’t put out an official ebook :slight_smile:

As to it not seeming right for moving + collision, the above code doesn’t seem to mention collision so I’m unsure what to suggest. [import]uid: 52491 topic_id: 27388 reply_id: 111277[/import]

Sorry, forget to mention…

[lua]local drawBackground = function()

background = display.newImageRect( “bg.png”, 570, 380 )
background.x = 240; background.y = 160

gameGroup:insert( background )

ground = display.newImageRect( “grass.png”, 570, 76 )
ground.x = 240; ground.y = 325

ground.myName = “ground”

local groundShape = { -285,-18, 285,-18, 285,18, -285,18 }
physics.addBody( ground, “static”, { density=1.0, bounce=0, friction=0.5, shape=groundShape } )

gameGroup:insert( ground )
end[/lua]

Again working with a device like the ipad 2 (think the res is at 1024x768 but this game is 768x1024) don’t get how the size would be modified.

[import]uid: 128294 topic_id: 27388 reply_id: 111283[/import]

I’m unsure on what your question is - you mentioned the collision stuff didn’t seem right + moving character.

The size of the game in config.lua that you seem to be referring to above would still have the same width and height regardless of whether or not it was landscape or portrait, that is for device dimensions.

I’m not quite sure what device this was meant to suit with the dimensions used above - I would really encourage you to contact the ebook author to find out if there is an update or the like.

If you have further questions specific to device size etc I can answer those but I can’t tell you much about what someone else’s code was written for I’m afraid. [import]uid: 52491 topic_id: 27388 reply_id: 111314[/import]

“The size of the game in config.lua that you seem to be referring to above would still have the same width and height regardless of whether or not it was landscape or portrait, that is for device dimensions.”

Seems as the quality of the images would decrease if it was blown up to the size of the ipad 2. That was my concern. It seems that it’s geared toward smaller devices, androids and ipod/iphone that at a horizontal position. [import]uid: 128294 topic_id: 27388 reply_id: 111408[/import]

I am very, very unsure of what exactly you are asking.

  • “think the res is at 1024x768 but this game is 768x1024”
    This is the most confusing. Those are the same sizes, one is just flipped on its side - the image size wouldn’t change unless you were trying to stretch one on the x axis or the y axis to change it from portrait to landscape or vice versa. [import]uid: 52491 topic_id: 27388 reply_id: 111469[/import]

“This is the most confusing. Those are the same sizes, one is just flipped on its side - the image size wouldn’t change unless you were trying to stretch one on the x axis or the y axis to change it from portrait to landscape or vice versa.”

Guess I should of said the game runs at landscape screen setting instead of portrait.

Not convinced that the objects in the game will look normal instead of stretched out. [import]uid: 128294 topic_id: 27388 reply_id: 111487[/import]

OK, so the game runs landscape instead of portrait - what is the question? Are you trying to make it run landscape? Or are you wanting to know how to modify the graphics?

When I say they wont stretch what I mean is if the game is written (config.lua) for a 1024x768 display then they will not stretch out when they are run on a 1024x768 display regardless of the orientation you choose because there will be no scaling. Scaling would only occur if you had an error in config.lua where you confused the width and height specified, eg, rather than specifying the real width and height you switched them. (Which people sometimes do by mistake when doing a landscape app not realizing they remain the same regardless of orientation.)

The background image in the above code for example would still not be stretched with the correct config.lua width and height settings for the iPad2 (768 width, 1024 height), however naturally it wouldn’t fill the screen as you state size as 570x380.

Peach :slight_smile: [import]uid: 52491 topic_id: 27388 reply_id: 111499[/import]