Hello, Director Class has proven to be a useful scene class so far, however it has some minor issues (or maybe I’m having some minor issues but anyways).
The setup I have currently works on the corona simulator. However, when I build the application for android, certain buttons cause a "Director ERROR: Failed to execute new( params ) function on 'crowbar."
Notice this only happens for certain buttons, as most of them work correctly on the android device, however some buttons AFTER the project has been built for android fail to function and cause that error on the android device.
Let me give some examples of what I’m talking about.
So of course you know the program starts in main.lua then goes to menu.lua. Then at menu.lua, you can hit the items button when goes to items.lua. Still working fine for both simulator and android. The items.lua presents the user with a large menu of choices. ALL of these choices are working perfectly fine in the simulator, but some of them (for no apparent reason) don’t work on the android build. Example, the axe button successfully opens axe.lua in both the simulator and android. But an example of one working on simulator but not on android is crowbar.lua. This button will open the crowbar.lua successfully in simulator, but on android will give "Director ERROR: Failed to execute new( params ) function on 'crowbar."
here’s my main.lua ( working on both simulator and android )
–plays sound in loop–
local main = audio.loadSound( “assets/audio/main.mp3” )
audio.play( main, {loops=-1} )
–background image–
local pzbackground = display.newImage( “assets/images/pzbackground.png” )
local director = require(“director”)
local mainGroup = display.newGroup()
local function main()
mainGroup:insert(director.directorView)
director:changeScene(“menu”)
return true
end
main ()
here’s my menu.lua ( working on both simulator and android build )
module(…, package.seeall)
local localGroup
function clean ( event )
print(“cleaned”)
end
function new()
local localGroup = display.newGroup()
--title–
local title = display.newText ( “Project Zomboid Survival Guide”, 20, 10, “Arial”, 20 )
title:setTextColor( 255,50,50 )
--buttons–
--buttons–
local buttonitem = display.newImage( “assets/images/button.png” )
buttonitem.x = display.contentWidth / 2
buttonitem.y = display.contentHeight / 4
local buttonitemtext = display.newText ( “Items”, display.contentWidth / 2.4, display.contentHeight / 4.4, “Arial”, 20 )
buttonitemtext:setTextColor( 255,50,50 )
--button items function–
function buttonitem:tap( event )
director:changeScene(“items”)
end
buttonitem:addEventListener( “tap”, buttonitem )
localGroup: insert(title)
localGroup: insert(buttonitem)
localGroup: insert(buttonitemtext)
return localGroup
end
heres my items.lua ( still working for both simulator and android )
module(…, package.seeall)
local localGroup
function clean ( event )
print(“cleaned”)
end
function new()
local localGroup = display.newGroup()
--title–
local title = display.newText ( “Items (Weapons)”, 110, 10, “Arial”, 20 )
title:setTextColor( 255,50,50 )
--buttons–
--buttons–
local buttonitem = display.newImage( “assets/images/button.png” )
local buttonitemtext = display.newText ( “Menu”, 25, 20, “Arial”, 20 )
buttonitemtext:setTextColor( 255,50,50 )
local buttonaxe = display.newImage( “assets/images/button.png” )
buttonaxe.y = display.contentHeight / 4
local buttonaxetext = display.newText ( “Axe”, 27, display.contentHeight / 4.4, “Arial”, 20 )
buttonaxetext:setTextColor( 255,50,50 )
local buttonhammer = display.newImage( “assets/images/button.png” )
buttonhammer.x = 140
buttonhammer.y = display.contentHeight / 4
local buttonhammertext = display.newText ( “Hammer”, 100, display.contentHeight / 4.4, “Arial”, 20 )
buttonhammertext:setTextColor( 255,50,50 )
local buttonbat = display.newImage( “assets/images/button.png” )
buttonbat.x = 230
buttonbat.y = display.contentHeight / 4
local buttonbattext = display.newText ( “Bat”, 210, display.contentHeight / 4.4, “Arial”, 20 )
buttonbattext:setTextColor( 255,50,50 )
local buttonsledge = display.newImage( “assets/images/button.png” )
buttonsledge.y = display.contentHeight / 2.8
local buttonsledgetext = display.newText ( “Sledge”, 21, display.contentHeight / 3, “Arial”, 20 )
buttonsledgetext:setTextColor( 255,50,50 )
local buttonspade = display.newImage( “assets/images/button.png” )
buttonspade.x = 140
buttonspade.y = display.contentHeight / 2.8
local buttonspadetext = display.newText ( “Spade”, 110, display.contentHeight / 3.0, “Arial”, 20 )
buttonspadetext:setTextColor( 255,50,50 )
local buttoncrowbar = display.newImage( “assets/images/button.png” )
buttoncrowbar.x = 230
buttoncrowbar.y = display.contentHeight / 2.8
local buttoncrowbartext = display.newText ( “Crowbar”, 195, display.contentHeight / 3.0, “Arial”, 20 )
buttoncrowbartext:setTextColor( 255,50,50 )
local buttonclub = display.newImage( “assets/images/button.png” )
buttonclub.y = display.contentHeight / 2.15
local buttonclubtext = display.newText ( “Golfclub”, 15, display.contentHeight / 2.25, “Arial”, 20 )
buttonclubtext:setTextColor( 255,50,50 )
local buttonroll = display.newImage( “assets/images/button.png” )
buttonroll.x = 140
buttonroll.y = display.contentHeight / 2.15
local buttonrolltext = display.newText ( “Rollingpin”, 96, display.contentHeight / 2.25, “Arial”, 20 )
buttonrolltext:setTextColor( 255,50,50 )
local buttonkknife = display.newImage( “assets/images/button.png” )
buttonkknife.x = 230
buttonkknife.y = display.contentHeight / 2.15
local buttonkknifetext = display.newText ( “Kitchen \nknife”, 200, display.contentHeight / 2.4, “Arial”, 20 )
buttonkknifetext:setTextColor( 255,50,50 )
local buttonbknife = display.newImage( “assets/images/button.png” )
buttonbknife.y = display.contentHeight / 1.75
local buttonbknifetext = display.newText ( “Butter \nknife”, 15, display.contentHeight / 1.90, “Arial”, 20 )
buttonbknifetext:setTextColor( 255,50,50 )
local buttonplank = display.newImage( “assets/images/button.png” )
buttonplank.x = 140
buttonplank.y = display.contentHeight / 1.75
local buttonplanktext = display.newText ( “Plank”, 115, display.contentHeight / 1.83, “Arial”, 20 )
buttonplanktext:setTextColor( 255,50,50 )
local buttonpool = display.newImage( “assets/images/button.png” )
buttonpool.x = 230
buttonpool.y = display.contentHeight / 1.75
local buttonpooltext = display.newText ( “Pool Cue”, 190, display.contentHeight / 1.83, “Arial”, 20 )
buttonpooltext:setTextColor( 255,50,50 )
local buttondrive = display.newImage( “assets/images/button.png” )
buttondrive.y = display.contentHeight / 1.47
local buttondrivetext = display.newText ( “Screw\ndriver”, 15, display.contentHeight / 1.58, “Arial”, 20 )
buttondrivetext:setTextColor( 255,50,50 )
local buttonpan = display.newImage( “assets/images/button.png” )
buttonpan.x = 140
buttonpan.y = display.contentHeight / 1.47
local buttonpantext = display.newText ( “Fryingpan”, 96, display.contentHeight / 1.53, “Arial”, 20 )
buttonpantext:setTextColor( 255,50,50 )
local buttonmisc = display.newImage( “assets/images/button.png” )
buttonmisc.x = 230
buttonmisc.y = display.contentHeight / 1.47
local buttonmisctext = display.newText ( “Spoon\nFork”, 200, display.contentHeight / 1.58, “Arial”, 20 )
buttonmisctext:setTextColor( 255,50,50 )
local buttonpen = display.newImage( “assets/images/button.png” )
buttonpen.y = display.contentHeight / 1.27
local buttonpentext = display.newText ( “Pen\nScissors”, 15, display.contentHeight / 1.35, “Arial”, 20 )
buttonpentext:setTextColor( 255,50,50 )
local buttonshotgun = display.newImage( “assets/images/button.png” )
buttonshotgun.x = 140
buttonshotgun.y = display.contentHeight / 1.27
local buttonshotguntext = display.newText ( “Shotgun”, 100, display.contentHeight / 1.31, “Arial”, 20 )
buttonshotguntext:setTextColor( 255,50,50 )
local buttonpistol = display.newImage( “assets/images/button.png” )
buttonpistol.x = 230
buttonpistol.y = display.contentHeight / 1.27
local buttonpistoltext = display.newText ( “Pistol”, 205, display.contentHeight / 1.31, “Arial”, 20 )
buttonpistoltext:setTextColor( 255,50,50 )
local buttonitems2 = display.newImage( “assets/images/button.png” )
buttonitems2.x = 230
buttonitems2.y = display.contentHeight / 1.05
local buttonitems2text = display.newText ( “Food”, 205, display.contentHeight / 1.08, “Arial”, 20 )
buttonitems2text:setTextColor( 255,50,50 )
--button items function–
function buttonitem:tap( event )
director:changeScene(“menu”)
end
buttonitem:addEventListener( “tap”, buttonitem )
function buttonaxe:tap( event )
director:changeScene(“axe”)
end
buttonaxe:addEventListener( “tap”, buttonaxe )
function buttonhammer:tap( event )
director:changeScene(“hammer”)
end
buttonhammer:addEventListener( “tap”, buttonhammer )
function buttonbat:tap( event )
director:changeScene(“bat”)
end
buttonbat:addEventListener( “tap”, buttonbat )
function buttonsledge:tap( event )
director:changeScene(“sledge”)
end
buttonsledge:addEventListener( “tap”, buttonsledge )
function buttonspade:tap( event )
director:changeScene(“spade”)
end
buttonspade:addEventListener( “tap”, buttonspade )
function buttoncrowbar:tap( event )
director:changeScene(“crowbar”)
end
buttoncrowbar:addEventListener( “tap”, buttoncrowbar )
function buttonclub:tap( event )
director:changeScene(“club”)
end
buttonclub:addEventListener( “tap”, buttonclub )
function buttonroll:tap( event )
director:changeScene(“roll”)
end
buttonroll:addEventListener( “tap”, buttonroll )
function buttonkknife:tap( event )
director:changeScene(“kknife”)
end
buttonkknife:addEventListener( “tap”, buttonkknife )
function buttonbknife:tap( event )
director:changeScene(“bknife”)
end
buttonbknife:addEventListener( “tap”, buttonbknife )
function buttonplank:tap( event )
director:changeScene(“plank”)
end
buttonplank:addEventListener( “tap”, buttonplank )
function buttonpool:tap( event )
director:changeScene(“pool”)
end
buttonpool:addEventListener( “tap”, buttonpool )
function buttondrive:tap( event )
director:changeScene(“drive”)
end
buttondrive:addEventListener( “tap”, buttondrive )
function buttonpan:tap( event )
director:changeScene(“pan”)
end
buttonpan:addEventListener( “tap”, buttonpan )
function buttonmisc:tap( event )
director:changeScene(“misc”)
end
buttonmisc:addEventListener( “tap”, buttonmisc )
function buttonpen:tap( event )
director:changeScene(“pen”)
end
buttonpen:addEventListener( “tap”, buttonpen )
function buttonshotgun:tap( event )
director:changeScene(“shotgun”)
end
buttonshotgun:addEventListener( “tap”, buttonshotgun )
function buttonpistol:tap( event )
director:changeScene(“pistol”)
end
buttonpistol:addEventListener( “tap”, buttonpistol )
function buttonitems2:tap( event )
director:changeScene(“items2”)
end
buttonitems2:addEventListener( “tap”, buttonitems2 )
localGroup: insert(title)
localGroup: insert(buttonitem)
localGroup: insert(buttonitemtext)
localGroup: insert(buttonaxe)
localGroup: insert(buttonaxetext)
localGroup: insert(buttonhammer)
localGroup: insert(buttonhammertext)
localGroup: insert(buttonbat)
localGroup: insert(buttonbattext)
localGroup: insert(buttonsledge)
localGroup: insert(buttonsledgetext)
localGroup: insert(buttonspade)
localGroup: insert(buttonspadetext)
localGroup: insert(buttoncrowbar)
localGroup: insert(buttoncrowbartext)
localGroup: insert(buttonclub)
localGroup: insert(buttonclubtext)
localGroup: insert(buttonroll)
localGroup: insert(buttonrolltext)
localGroup: insert(buttonkknife)
localGroup: insert(buttonkknifetext)
localGroup: insert(buttonbknife)
localGroup: insert(buttonbknifetext)
localGroup: insert(buttonplank)
localGroup: insert(buttonplanktext)
localGroup: insert(buttonpool)
localGroup: insert(buttonpooltext)
localGroup: insert(buttondrive)
localGroup: insert(buttondrivetext)
localGroup: insert(buttonpan)
localGroup: insert(buttonpantext)
localGroup: insert(buttonmisc)
localGroup: insert(buttonmisctext)
localGroup: insert(buttonpen)
localGroup: insert(buttonpentext)
localGroup: insert(buttonshotgun)
localGroup: insert(buttonshotguntext)
localGroup: insert(buttonpistol)
localGroup: insert(buttonpistoltext)
localGroup: insert(buttonitems2)
localGroup: insert(buttonitems2text)
return localGroup
end
Working Axe.lua ( works on both simulator and android )
module(…, package.seeall)
local localGroup
function clean ( event )
print(“cleaned”)
end
function new()
local localGroup = display.newGroup()
--title–
local title = display.newText ( “Axe”, 140, 10, “Arial”, 20 )
title:setTextColor( 255,50,50 )
--item information–
local item = display.newImage (“assets/images/axe.png”)
item.x = display.contentWidth / 1.2
local itemtext = display.newText ( “A good anti-zombie weapon, \ntree chopper, and door-breaker, \nalthough it’s a little bit on the heavy \nside. Also great for chopping trees.”, 5, display.contentHeight/ 4, “Arial”, 20)
itemtext:setTextColor( 255,0,0 )
--buttons–
--buttons–
local buttonitem = display.newImage( “assets/images/button.png” )
local buttonitemtext = display.newText ( “Back”, 25, 20, “Arial”, 20 )
buttonitemtext:setTextColor( 255,50,50 )
--button items function–
function buttonitem:tap( event )
director:changeScene(“items”)
end
buttonitem:addEventListener( “tap”, buttonitem )
localGroup: insert(title)
localGroup: insert(buttonitem)
localGroup: insert(buttonitemtext)
localGroup: insert(item)
localGroup: insert(itemtext)
return localGroup
end
not working crowbar.lua ( working on simulator but NOT on android build )
module(…, package.seeall)
local localGroup
function clean ( event )
print(“cleaned”)
end
function new()
local localGroup = display.newGroup()
--title–
local title = display.newText ( “Crowbar”, 140, 10, “Arial”, 20 )
title:setTextColor( 255,50,50 )
--item information–
local item = display.newImage (“assets/images/crowbar.png”)
item.x = display.contentWidth / 1.2
local itemtext = display.newText ( “A long iron bar with a clawed edge, \nit may be heavy but it is quite \ndurable and is capable of crushing \na few skulls before becoming \nunusable.”, 5, display.contentHeight/ 4, “Arial”, 20)
itemtext:setTextColor( 255,0,0 )
--buttons–
--buttons–
local buttonitem = display.newImage( “assets/images/button.png” )
local buttonitemtext = display.newText ( “Back”, 25, 20, “Arial”, 20 )
buttonitemtext:setTextColor( 255,50,50 )
--button items function–
function buttonitem:tap( event )
director:changeScene(“items”)
end
buttonitem:addEventListener( “tap”, buttonitem )
localGroup: insert(title)
localGroup: insert(buttonitem)
localGroup: insert(buttonitemtext)
localGroup: insert(item)
localGroup: insert(itemtext)
return localGroup
end
Final Notes:: I’ve only had a chance to test it on one android device. Perhaps it is somehow incompatible with this device? If anyone wants to try a test build on their device and see if they get same results, please ask so. Also, that wasn’t my whole program. I’ve got like 40 lua files lol. I just submitted enough to try to explain what’s going on.
~thx, Jarrin Rantz