Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Unable to load a polygon shape correctly
Started by stephen.ho.232 Jan 11 2020 10:05 AM

2 replies to this topic

Best Answer ldurniat , 13 January 2020 - 04:22 AM

Hi @stephen.ho.232,

 

You misspelled the word. It shoud be 'height' not 'heigh'.

 

Try (tested)

local menuSpriteSheet = {
        frames={
            {
                x     = 0,
                y     = 0,
                width = 102, --175,
                height = 87, --150
            },
            {
                x     = 103,--175,
                y     = 0,
                width = 230-103,--244,
                height = 69,--119
            }
        }
    }
    local menuAtlas = graphics.newImageSheet("thumb.png",menuSpriteSheet)
    --local playBtnSprite = display.newImageRect(menuAtlas,2,244,119)
    local playBtnSprite = display.newImageRect(menuAtlas,2,230-103,69)

Have a nice day:)

ldurniat

 

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

stephen.ho.232

[GLOBAL: userInfoPane.html]
stephen.ho.232
  • Observer

  • 2 posts
  • Corona SDK

Hi guys, I am new to Corona SDK.

Currently I wanna render a button which is polygon shape. I put it in a big atlas and use Sprite Sheet to render it and cut it into frame. But the final result is not as what I expected. It only showed the rectangle shape of the polygon.

The final result

Attached File  res.PNG   31.44KB   0 downloads

The expectation

Attached File  expect.PNG   767bytes   0 downloads

My original sprite sheet

Attached File  ui-asset.png   9.51KB   0 downloads

My code I used to load it

local menuSpriteSheet = {
        frames={
            {
                x     = 0,
                y     = 0,
                width = 175,
                heigh = 150
            },
            {
                x     = 175,
                y     = 0,
                width = 244,
                heigh = 119
            }
        }

    }
    local menuAtlas = graphics.newImageSheet("asset/ui-asset.png",menuSpriteSheet)
    local playBtnSprite = display.newImageRect(menuAtlas,2,244,119)
    playBtnSprite.x = display.contentCenterX
    playBtnSprite.y = display.contentCenterY

I tested out with single png file with another polygon shape and not using Image Sheet to load it, only use newImageRect and magically, I can load it. I am so confused at this case.
 

 



[TOPIC: post.html]
#2

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 400 posts
  • Corona SDK

  Best Answer

Hi @stephen.ho.232,

 

You misspelled the word. It shoud be 'height' not 'heigh'.

 

Try (tested)

local menuSpriteSheet = {
        frames={
            {
                x     = 0,
                y     = 0,
                width = 102, --175,
                height = 87, --150
            },
            {
                x     = 103,--175,
                y     = 0,
                width = 230-103,--244,
                height = 69,--119
            }
        }
    }
    local menuAtlas = graphics.newImageSheet("thumb.png",menuSpriteSheet)
    --local playBtnSprite = display.newImageRect(menuAtlas,2,244,119)
    local playBtnSprite = display.newImageRect(menuAtlas,2,230-103,69)

Have a nice day:)

ldurniat

 



[TOPIC: post.html]
#3

stephen.ho.232

[GLOBAL: userInfoPane.html]
stephen.ho.232
  • Observer

  • 2 posts
  • Corona SDK

Thanks for help @Idurniat :D. It lit up my way of debug processing.




[topic_controls]
[/topic_controls]