2016년 2월 14일 일요일

@2x 이미지가 동작하지(loading 되지) 않을 때 in corona sdk


아래와 같이 구현해놓고 @2x 이미지까지 모두 준비된 상태에서 적절한 이미지가 올라오지않는 경우가 있다.

local buttonArrow = widget.newButton
{
id = "arrow",
defaultFile = "btn_play.png",
overFile = "img/btn_play_pushed.png",
onEvent = buttonHandler,
}

buttonArrow.x = CWidth/2; buttonArrow.y = CHeight/2
sceneGroup:insert(buttonArrow)


@2x 이미지를 사용하는 방법에 대해서는 여기 설명 참고
https://coronalabs.com/blog/2013/09/10/modernizing-the-config-lua/

번역된 예제 
원본 예제

동일 질문
https://forums.coronalabs.com/topic/45519-dinamic-sprite-images-for-widgetnewbutton/
아무도 답변은 없다...
이것 때문에 오랬동안 삽질했다.








해결책

버튼의 크기를 꼭 기록 해야합니다.

local buttonArrow = widget.newButton
{
id = "arrow",
        width = 220, -- this defines the width of the button
        height = 100, -- this defines the height of the button 
defaultFile = "btn_play.png",
overFile = "img/btn_play_pushed.png",
onEvent = buttonHandler,
}

이런 예제라면 이미지 로딩에 크기정보를 꼭 기록 하기 바랍니다.
local bg = display.newImageRect("splash.png",480,320)

댓글 없음:

댓글 쓰기