Handling Sprites with multiple sizes

So attached is a sprite sheet with different sized sprites.

I want them all to be scaled to the size of the banana when displayed in corona.

Without physically changing the size of the pictures and not knowing what the dimensions of the sprites should be made to, how would i do it within corona.

Here is the spritesheet code:

-- -- created with TexturePacker (http://www.codeandweb.com/texturepacker) -- -- $TexturePacker:SmartUpdate:abc8a79cec71f81c2d734456506cbd9e:4ce07956c8b11ae5004161f200ff782a:9c519dc4da464f2a30daa98e61c4961f$ -- -- local sheetInfo = require("mysheet") -- local myImageSheet = graphics.newImageSheet( "mysheet.png", sheetInfo:getSheet() ) -- local sprite = display.newSprite( myImageSheet , {frames={sheetInfo:getFrameIndex("sprite")}} ) -- local SheetInfo = {} SheetInfo.sheet = { frames = { { -- Charmander x=3047, y=1, width=354, height=408, sourceX = 31, sourceY = 5, sourceWidth = 420, sourceHeight = 420 }, { -- Banana x=3047, y=669, width=234, height=146, sourceX = 8, sourceY = 33, sourceWidth = 256, sourceHeight = 256 }, { -- Zelda x=1, y=1, width=642, height=862, sourceX = 39, sourceY = 19, sourceWidth = 700, sourceHeight = 900 }, { -- Car x=645, y=1, width=2400, height=852, }, { -- Dog x=3047, y=411, width=256, height=256, }, }, sheetContentWidth = 3402, sheetContentHeight = 864 } SheetInfo.frameIndex = { ["Charmander"] = 1, ["Banana"] = 2, ["Zelda"] = 3, ["Car"] = 4, ["Dog"] = 5, } function SheetInfo:getSheet() return self.sheet; end function SheetInfo:getFrameIndex(name) return self.frameIndex[name]; end return SheetInfo

The approach you describe here is wrong in several ways. I recommend you read the documentation

I would simply ensure that all sprites are shown at a specific relative size like this:

-- pseudo-code follows -- ONLY USE ONE (or it won't maintain the aspect ratio of the sprite) local width = 100 --local height = 100 local sprite = display.newSprite( ... ) local newScale = width/sprite.contentWidth --local newScale = height/sprite.contentHeight -- if you do height-scaling use this code INSTEAD sprite.xScale = newScale sprite.yScale = newScale -- Now all sprites will be proportionately scaled to ensure they are 100 pixels wide

Hi and thanks for your replies. This was sort of a casual question I asked. I think the best way of doing this is just to separately scale everything.

The approach you describe here is wrong in several ways. I recommend you read the documentation

I would simply ensure that all sprites are shown at a specific relative size like this:

-- pseudo-code follows -- ONLY USE ONE (or it won't maintain the aspect ratio of the sprite) local width = 100 --local height = 100 local sprite = display.newSprite( ... ) local newScale = width/sprite.contentWidth --local newScale = height/sprite.contentHeight -- if you do height-scaling use this code INSTEAD sprite.xScale = newScale sprite.yScale = newScale -- Now all sprites will be proportionately scaled to ensure they are 100 pixels wide

Hi and thanks for your replies. This was sort of a casual question I asked. I think the best way of doing this is just to separately scale everything.