Hi, this is really confusing for me. The app works perfectly in the simulator but just gives a blank screen and crashes with NO error messages on my HTC Desire HD when pressing the start game button.
Here is the main.lua file that just loads up the menu.lua file.
This works!
\_H = display.contentHeight;
\_W = display.contentWidth;
local director = require("director");
local mainGroup = display.newGroup();
local function main()
mainGroup:insert(director.directorView);
director:changeScene("menu");
return true;
end
main();
This is the menu.lua file, which crashes the app when pressing on the text to go to the game.lua file.
[code]module(…, package.seeall)
function new()
local localGroup = display.newGroup();
– Use the system name for the font (click on font)
– *2 = Retina Display Support
local hello = display.newText(“Tap me, and magic happens!”, 0, 0, “BorisBlackBloxx”, 24*2)
– Xscale = retina support
hello.xScale = 0.5; hello.yScale = 0.5;
hello.x = _W * 0.5; hello.y = _H * 0.5;
hello.scene = “game”;
function changeScene(e)
if(e.phase == “ended”) then
– e.target is in this case = “game”)
director:changeScene(e.target.scene);
end
end
localGroup:insert(hello);
– Adds a touch event to the buttons and activates the function
hello:addEventListener(“touch”, changeScene);
return localGroup;
end[/code]
And this is the game.lua file that never loads:
module(..., package.seeall)
function new()
local localGroup = display.newGroup();
local hero = display.newImageRect("images/hero.png", 100, 82);
hero:setReferencePoint(display.CenterReferencePoint);
hero.x = \_W/2; hero.y = \_H/2;
local touchleft = display.newImageRect("images/leftbutton.png", 51, 48);
touchleft:setReferencePoint(display.CenterReferencePoint);
touchleft.x = 40; touchleft.y = 210;
local touchright = display.newImageRect("images/leftbutton.png", 51, 48);
touchright:setReferencePoint(display.CenterReferencePoint);
touchright.x = 140; touchright.y = 210;
touchright.rotation = -180;
local touchdown = display.newImageRect("images/leftbutton.png", 51, 48);
touchdown:setReferencePoint(display.CenterReferencePoint);
touchdown.x = 90; touchdown.y = 260;
touchdown.rotation = -90;
local touchup = display.newImageRect("images/leftbutton.png", 51, 48);
touchup:setReferencePoint(display.CenterReferencePoint);
touchup.x = 90; touchup.y = 160;
touchup.rotation = 90;
function touchleft1(e)
if(e.phase == "ended") then
transition.to(hero, {time = 1000, x= hero.x - hero.width});
end
end
function touchright1(e)
if(e.phase == "ended") then
transition.to(hero, {time = 1000, x= hero.x + hero.width});
end
end
function touchdown1(e)
if(e.phase == "ended") then
transition.to(hero, {time = 1000, y= hero.y + hero.width});
end
end
function touchup1(e)
if(e.phase == "ended") then
transition.to(hero, {time = 1000, y= hero.y - hero.width});
end
end
localGroup:insert(hero);
localGroup:insert(touchleft);
localGroup:insert(touchright);
localGroup:insert(touchdown);
localGroup:insert(touchup);
touchleft:addEventListener("touch", touchleft1);
touchright:addEventListener("touch", touchright1);
touchdown:addEventListener("touch", touchdown1);
touchup:addEventListener("touch", touchup1);
return localGroup;
end
Does anyone have any idea what may be causing this?
Thanks in advance,
Fredrik [import]uid: 43150 topic_id: 7779 reply_id: 307779[/import]