@jbp1 Thank you so much for the links about json. They’ve been helpful. I’m still having some trouble so i hope you don’t mind if I ask you a few more questions. (sorry for the long post)
This is what I have for the loading screen in JSON:
{
“appcontents”: [
{
“url”: “Assets/titleBg.png”,
“xPos”: 160,
“yPos”: 512,
“name”:“title”
},
{
“url”: “Assets/button.png”,
“xPos”: 160,
“yPos”: 160,
“name”:“button”
},
{
“url”: “Assets/button-over.png”,
“xPos”: 160,
“yPos”: 160,
“name”:“button”
}
],
And this is what I have in the contentLoader.lua file:
function functionTable.loadTable(filename)
local path= system.pathForFile(filename, system.ResourceDirectory)
local contents=""
local myTable= {}
local file= io.open(path, “r”)
if file then
local contents= file:read("*a")
local jsonContents= json.decode(contents)
functionTable.appContentsData = jsonContents.appcontents --calls the separate parts of json
io.close(file)
end
local displayObjectRef
for i=1, #functionTable.appContentsData do
print(functionTable.appContentsData[i].url)
displayObjectRef = display.newImage(functionTable.appContentsData[i].url)
displayObjectRef.anchorX=0
displayObjectRef.anchorY=0
displayObjectRef.x= functionTable.appContentsData[i].xPos
print(i…"."…i)
displayObjectRef.y= functionTable.appContentsData[i].yPos
print(i…"."…i)
displayObjectRef.name= functionTable.appContentsData[i].name
– if functionTable.hudConfigData[i].name== “button” then
– print(functionTable.hudConfigData[i].url)
– displayObjectRef:addEventListener(“touch”, functionTable.touchHandler)
– end
functionTable.displayGroup : insert(displayObjectRef)
end
end
return functionTable
*************************
It is working but every time I click on the button showing in the simulator the second button moves…see attached screenshot to see what I mean… Can you help? I want it work so that it transitions to scene 1 then scene 2 but having trouble doing that.