2014-02-16 5 views
1

나는 유성이 문자쪽으로 떨어지고 코로나 시뮬레이터가 오류를 던지는 프로그램을 가지고있다. "지역 '배경'을 색인하려고 시도한다. (나는 아무 가치도 없다.)"나는이 사실을 알고 있으며 누군가가 도울 수 있기를 바라고있다!배경은 무효입니까?

Relavent 코드 :

--Start the physics engine! 
local physics = require ("physics") 

--Get a background image! 
local screen_adjustment = 1 
local background = display.newImage("Images/Background", true) 
background.xScale = (screen_adjustment*background.contentWidth)/background.contentWidth 
background.yScale = background.xScale 
background.x = display.contentWidth/2 
background.y = display.contentHeight/2 

답변

0

이미지를 만들지 못해서 이미지가 nil입니다. 파일 이름과 경로를 다시 확인하십시오. Background.png의 확장 기능을 잊어 버리고 있습니까?

1

display.newImage 반환 nil. 대부분 Images/Background이라는 파일이 없기 때문일 수 있습니다.

1

display.newImage에 주어진 파일 이름은 (기본값으로) main.lua이 들어있는 폴더와 동일한 폴더 인 앱의 resources 디렉토리에 있다고 가정합니다. 따라서 코드는 main.lua이 들어있는 폴더에 Images이라는 폴더가 있고 그 안에 Background이라는 파일이 있다고 가정합니다. 확장자는 Background.png과 같이 지정해야합니다.

관련 문제