I just grabbed a copy of CPM and I love it a lot, but one strange thing though.
When I build in Corona Simulator alone my project build and works just fine but when I added it to CPM and build it I get this error and it wont work?
WARNING: Failed to find image(images/background.png)
Runtime error
…1HGkKXNH+WWf6ydHU3uW++++TI/TemporaryItems/3/main.lua:41: attempt to index local ‘b
ackgroundImg’ (a nil value)
stack traceback:
[C]: ?
…1HGkKXNH+WWf6ydHU3uW++++TI/TemporaryItems/3/main.lua:41: in main chunk
Runtime error: …1HGkKXNH+WWf6ydHU3uW++++TI/TemporaryItems/3/main.lua:41: attempt to index local ‘backgroundImg’ (
a nil value)
stack traceback:
[C]: ?
…1HGkKXNH+WWf6ydHU3uW++++TI/TemporaryItems/3/main.lua:41: in main chunk [import]uid: 34126 topic_id: 6335 reply_id: 306335[/import]
Here is the code that doesn’t work when launched from CPM, works fine in simulator:
[lua]local physics = require (“physics”)
physics.start()
local floor = display.newImage(“ground.png”, 0, 800)
physics.addBody(floor, “static”)
local red_button = display.newImage(“red_button.png”, 324, 685)
– image loads and displays fine here
local ball = display.newImage(“ball.png”)
ball.x = math.ceil(red_button.x)
ball.y = math.ceil(red_button.y)
physics.addBody(ball)
function onButtonClick(event)
– error happens here
– WARNING: Failed to find image(ball.png)
local ball = display.newImage(“ball.png”, red_button.x, red_button.y)
end
Are you absolutely positive ball.png (spelled that way INCLUDING case) is at that location?
I haven’t done much testing with projects being on D: and CPM on C:, so not sure if that could be a problem or not. I’ll go poke at that and see what happens.
However…
If you confirm that the file is there, try this – hit the Launch button in CPM and wait to get the error from Corona Simulator. Then go to the Simulator and choose File > Relaunch and let me know if anything different happens (as in, it runs).
Jay [import]uid: 9440 topic_id: 6335 reply_id: 25467[/import]
The error occurs on touching the red_button. I know that the ball.png is correct because it loads the image outside of the event function. It only fails when red_button is touched and onButtonClick is fired.
When I relaunch the project in the simulator it works fine, oddly enough.
CPM is actually installed on D:, but Corona Simulator is on C: if that helps at all.
Thanks for your help. [import]uid: 37867 topic_id: 6335 reply_id: 25469[/import]
When I relaunch the project in the simulator it works fine, oddly enough.
Bummer, because it means I can’t help you – yet.
It appears to be a bug in the Windows version of Corona Simulator. When launched via the command line it doesn’t “see” at least some of the files until you relaunch the Simulator itself.
Right now the only way I can launch the Simulator with a project from CPM is via the command line, but that should be changing in the next release of Corona SDK. Ansca is putting in a way to tell the Simulator to load a give project, which means I won’t have to launch the Simulator each time, just tell it to (re)load the project.
What’s frustrating is that some projects work fine via the command line and some don’t. In fact, I never found any that didn’t work until after the Windows version of CPM was released (ain’t that always the way).
I’m hoping the new version of Corona SDK is released soon – I figure it can’t be too much longer.
Thanks.
Jay
[import]uid: 9440 topic_id: 6335 reply_id: 25471[/import]
Complete Noob here, so probably it is user error.
Here is what I have done.
I have started completely new project
so all files are fresh
i have added 1 image to the subfolder images
image is retina wallpaper file form internet, jpeg ext.
and only line of code is to show that image as background
main.lua :
local background1=display.newImage(“images/background1.jpg”)
i have added image to the assets window by hand, no auto show there.
directory structure is like this:
Desktop \ CORONA X \ X2 \ images \ background1.jpg
[edit]
i have just tried to change d.s. to:
Desktop \ CORONA_X \ X2 \ images \ background1.jpg
no change
Also no aliases.
Same project is working fine when opened from Corona directly.
Please Help [import]uid: 73847 topic_id: 6335 reply_id: 49175[/import]
If you have a subfolder called images in your projects, and then go add an image to the folder on your hard drive, it does not exist in the project.
The subfolder you create in your project is not tied to the folder of the same name on your hard drive – well, it is if you drag and drop the folder into your project, but only the files that exist in the subfolder at that time are added as assets.
That is by design, although it will probably change in an upcoming version.
In CPM, double-click the images folder in the asset list – if background1.jpg doesn’t show up, drag it from the hard drive into the asset list (into the images folder). Now try launching CPM again.
If you *do* see background1.jpg inside that subfolder, take a screenshot of CPM (so I can see the project and the asset list) and send it to j at jawhye [com] and I’ll figure out what’s happening.
Jay
[import]uid: 9440 topic_id: 6335 reply_id: 49239[/import]
According to CPM you have your background1.jpg image at the same level as main.lua, but inside the code you say it’s down in a folder.
While the image *does* live on your hard drive down in a folder, CPM doesn’t care about that – it’s a feature. It allows you to use assets from any folder in any other project.
Two ways to fix this – change your code to take out the images/ part, or drag your images folder into the asset list. If you do that, all contents of the images folder AT THAT TIME will become assets of the project.
I hope that helps.
Jay
[import]uid: 9440 topic_id: 6335 reply_id: 50062[/import]
As usual You Always find a way to solve the problem, even if it is noob user generated.
Thank You for Your great understanding and support.
Best Regards [import]uid: 73847 topic_id: 6335 reply_id: 50414[/import]