I am using an sqlite database to save all of my character’s information. I’m stuck on one problem. Basically, I want to save a created character’s image. For example, human, hair, hair color are all saved to the database. How do I load the correct images based on that though? Also, i want to be able to save it all together as one display group. Reason being the character is going to be animated. Currently I’m able to display the correct information while the game is running. All of the text information is saved correctly to the database. I just am not sure how to save an image’s information to the database. [import]uid: 74407 topic_id: 20762 reply_id: 320762[/import]
My suggestion would be to save strings of the image file names. Then you can easily load them back in [import]uid: 84637 topic_id: 20762 reply_id: 81676[/import]
once i save the strings of the file names how can i load them back into the display group? [import]uid: 74407 topic_id: 20762 reply_id: 81737[/import]
Well your saving a group of data so something like this
Psudo code
local background, player
if fileExists(“background”) then
background = display.newImage(“background”)
end
group:insert(background) [import]uid: 84637 topic_id: 20762 reply_id: 81738[/import]
What is the fileExists for?
Here let me post an example of my character generation.
If you look at the code, you can see that pressing the next button saves the player’s name, race, class, hair, hair color, and level. I’m wondering if I can save the display group as a variable that way.
Also, if you look at the right and left arrows for hair and hair color. They change the image of the style and color correctly. I basically want to save that. I think that the easiest way to do that. Would be to just use the hair and hair color variables and load the correct images from those values.
But even then, I would still need to figure out how to create the display group at run time from the image variables.
So basically, if hair == messy and hair_color == blue then display the correct images. But, I want there to be an easier way then just checking for every single possible value. If that’s possible as well.
Then after the images are displayed, add them to the display group. Or, if I can, save the display group and only have to load that from the SQL database.
[lua]module(…, package.seeall)
–====================================================================–
– SCENE: [Character Creation Screen]
–====================================================================–
–[[
- Version: [1.0]
- Made by: [Malik Gray]
- Website: [www.erydyn.com]
- Mail: [mikey@starfantasygames.com]
******************
-
INFORMATION
****************** -
[Character Creation Screen allows the player to choose their race, hair, hair color,
and facial expressions.]
–]]
new = function ()
– Groups
local localGroup = display.newGroup()
– Your code here
local ui = require ( “ui” )
require “sqlite3”
local path = system.pathForFile ( “playerData.db”, system.DocumentsDirectory )
db = sqlite3.open( path )
local function onSystemEvent( event )
if( event.type == “applicationExit” ) then
db:close()
end
end
local tablesetup = [[CREATE TABLE IF NOT EXISTS playerCharData ( id INTEGER PRIMARY KEY, Name, Race, Hair, Hair_Color, Face, Class, Level);]]
db:exec( tablesetup )
local bg = display.newImageRect( “BoH_CharGen_BG.png”, 480, 320 )
bg.x = display.contentWidth / 2
bg.y = display.contentHeight / 2
localGroup:insert(bg)
local human_body = display.newImageRect( “Squire_Body.png”, 113, 188 )
human_body.x = display.contentWidth / 4
human_body.y = (display.contentHeight / 4) * 2
localGroup:insert(human_body)
local human_head = display.newImageRect( “BoH_Head_Base.png”, 25, 29 )
human_head:setReferencePoint(display.CenterReferencePoint)
human_head.x = (display.contentWidth / 4) - 11
human_head.y = (display.contentHeight / 3) + 8
localGroup:insert(human_head)
local hair_messy_blue = display.newImageRect( “BoH_Hair_Messy_Blue.png”, 39, 34 )
hair_messy_blue.x = (display.contentWidth / 4) - 11
hair_messy_blue.y = (display.contentHeight / 3)
hair_messy_blue.isVisible = false
localGroup:insert(hair_messy_blue)
local hair_messy_brown = display.newImageRect( “BoH_Hair_Messy_Brown.png”, 39, 34 )
hair_messy_brown.x = (display.contentWidth / 4) - 11
hair_messy_brown.y = (display.contentHeight / 3)
hair_messy_brown.isVisible = false
localGroup:insert(hair_messy_brown)
local hair_messy_midnightblue = display.newImageRect( “BoH_Hair_Messy_MidnightBlue.png”, 39, 34 )
hair_messy_midnightblue.x = (display.contentWidth / 4) - 11
hair_messy_midnightblue.y = (display.contentHeight / 3)
hair_messy_midnightblue.isVisible = false
localGroup:insert(hair_messy_midnightblue)
local hair_messy_purple = display.newImageRect( “BoH_Hair_Messy_Purple.png”, 39, 34 )
hair_messy_purple.x = (display.contentWidth / 4) - 11
hair_messy_purple.y = (display.contentHeight / 3)
hair_messy_purple.isVisible = false
localGroup:insert(hair_messy_purple)
local hair_messy_yellow = display.newImageRect( “BoH_Hair_Messy_Yellow.png”, 39, 34 )
hair_messy_yellow.x = (display.contentWidth / 4) - 11
hair_messy_yellow.y = (display.contentHeight / 3)
hair_messy_yellow.isVisible = false
localGroup:insert(hair_messy_yellow)
local hair_spike_blue = display.newImageRect( “BoH_Hair_Spike_Blue.png”, 31, 42 )
hair_spike_blue.x = (display.contentWidth / 4) - 11
hair_spike_blue.y = (display.contentHeight / 3) - 3
hair_spike_blue.isVisible = false
localGroup:insert(hair_spike_blue)
local hair_spike_brown = display.newImageRect( “BoH_Hair_Spike_Brown.png”, 31, 42 )
hair_spike_brown.x = (display.contentWidth / 4) - 11
hair_spike_brown.y = (display.contentHeight / 3) - 3
hair_spike_brown.isVisible = false
localGroup:insert(hair_spike_brown)
local hair_spike_midnightblue = display.newImageRect( “BoH_Hair_Spike_MidnightBlue.png”, 31, 42 )
hair_spike_midnightblue.x = (display.contentWidth / 4) - 11
hair_spike_midnightblue.y = (display.contentHeight / 3) - 3
hair_spike_midnightblue.isVisible = false
localGroup:insert(hair_spike_midnightblue)
local hair_spike_purple = display.newImageRect( “BoH_Hair_Spike_Purple.png”, 31, 42 )
hair_spike_purple.x = (display.contentWidth / 4) - 11
hair_spike_purple.y = (display.contentHeight / 3) - 3
hair_spike_purple.isVisible = false
localGroup:insert(hair_spike_purple)
local hair_spike_yellow = display.newImageRect( “BoH_Hair_Spike_Yellow.png”, 31, 42 )
hair_spike_yellow.x = (display.contentWidth / 4) - 11
hair_spike_yellow.y = (display.contentHeight / 3) - 3
hair_spike_yellow.isVisible = false
localGroup:insert(hair_spike_yellow)
local hair_messy = { [1] = hair_messy_blue, [2] = hair_messy_brown, [3] = hair_messy_midnightblue, [4] = hair_messy_purple, [5] = hair_messy_yellow}
local hair_spike = { [1] = hair_spike_blue, [2] = hair_spike_brown, [3] = hair_spike_midnightblue, [4] = hair_spike_purple, [5] = hair_spike_yellow}
tempName = “Name”
tempRace = “Human”
tempHair = “Short”
tempHair_Color = “Blue”
tempFace = “Happy”
local raceTitle = ui.newLabel{
bounds = { 0, 0, 88, 46 },
text = “Race”,
font = “Algerian”,
textColor = { 200, 255, 255, 255 },
size = 18
}
localGroup:insert(raceTitle)
if (deviceModel == “iPad”) then
raceTitle.x = display.contentWidth * 0.585
else
raceTitle.x = display.contentWidth * 0.62
end
raceTitle.y = display.contentHeight * 0.25
race = { [1] = “Human”, [2] = “Orc”, [3] = “Dwarf”, [4] = “Elf” }
local i = 1
local raceText = ui.newLabel{
bounds = { 0, 0, 88, 46 },
text = race[i],
font = “Algerian”,
textColor = { 255, 255, 255, 255 },
size = 28
}
localGroup:insert(raceText)
if (deviceModel == “iPad”) then
raceText.x = display.contentWidth * 0.585
else
raceText.x = display.contentWidth * 0.62
end
raceText.y = display.contentHeight * 0.15
local R_Arrow_Race = function( event )
i = i + 1
raceText:setText(race[i])
if i == 5 then
i = 1
raceText:setText(race[i])
end
tempRace = race[i]
return tempRace
end
local L_Arrow_Race = function( event )
i = i - 1
raceText:setText(race[i])
if i == 0 then
i = 4
raceText:setText(race[i])
end
tempRace = race[i]
return tempRace
end
local hairTitle = ui.newLabel{
bounds = { 0, 0, 88, 46 },
text = “Hair Style”,
font = “Algerian”,
textColor = { 200, 255, 255, 255 },
size = 18
}
localGroup:insert(hairTitle)
if (deviceModel == “iPad”) then
hairTitle.x = display.contentWidth * 0.585
else
hairTitle.x = display.contentWidth * 0.62
end
hairTitle.y = display.contentHeight * 0.41
hair = { [1] = “Short”, [2] = “Messy”, [3] = “Long”, [4] = “Spikey” }
local i = 1
local hairText = ui.newLabel{
bounds = { 0, 0, 88, 46 },
text = hair[i],
font = “Algerian”,
textColor = { 255, 255, 255, 255 },
size = 28
}
localGroup:insert(hairText)
if (deviceModel == “iPad”) then
hairText.x = display.contentWidth * 0.585
else
hairText.x = display.contentWidth * 0.62
end
hairText.y = display.contentHeight * 0.31
local R_Arrow_Hair = function( event )
i = i + 1
hairText:setText(hair[i])
if i == 5 then
i = 1
hairText:setText(hair[i])
end
tempHair = hair[i]
if(tempHair == “Messy” and tempHair_Color == “Blue”) then
hair_messy[1].isVisible = true
else
hair_messy[1].isVisible = false
end
if(tempHair == “Messy” and tempHair_Color == “Brown”) then
hair_messy[2].isVisible = true
else
hair_messy[2].isVisible = false
end
if(tempHair == “Messy” and tempHair_Color == “Midnight Blue”) then
hair_messy[3].isVisible = true
else
hair_messy[3].isVisible = false
end
if(tempHair == “Messy” and tempHair_Color == “Purple”) then
hair_messy[4].isVisible = true
else
hair_messy[4].isVisible = false
end
if(tempHair == “Messy” and tempHair_Color == “Yellow”) then
hair_messy[5].isVisible = true
else
hair_messy[5].isVisible = false
end
if(tempHair == “Spikey” and tempHair_Color == “Blue”) then
hair_spike[1].isVisible = true
else
hair_spike[1].isVisible = false
end
if(tempHair == “Spikey” and tempHair_Color == “Brown”) then
hair_spike[2].isVisible = true
else
hair_spike[2].isVisible = false
end
if(tempHair == “Spikey” and tempHair_Color == “Midnight Blue”) then
hair_spike[3].isVisible = true
else
hair_spike[3].isVisible = false
end
if(tempHair == “Spikey” and tempHair_Color == “Purple”) then
hair_spike[4].isVisible = true
else
hair_spike[4].isVisible = false
end
if(tempHair == “Spikey” and tempHair_Color == “Yellow”) then
hair_spike[5].isVisible = true
else
hair_spike[5].isVisible = false
end
return tempHair
end
local L_Arrow_Hair = function( event )
i = i - 1
hairText:setText(hair[i])
if i == 0 then
i = 4
hairText:setText(hair[i])
end
tempHair = hair[i]
if(tempHair == “Messy” and tempHair_Color == “Blue”) then
hair_messy[1].isVisible = true
else
hair_messy[1].isVisible = false
end
if(tempHair == “Messy” and tempHair_Color == “Brown”) then
hair_messy[2].isVisible = true
else
hair_messy[2].isVisible = false
end
if(tempHair == “Messy” and tempHair_Color == “Midnight Blue”) then
hair_messy[3].isVisible = true
else
hair_messy[3].isVisible = false
end
if(tempHair == “Messy” and tempHair_Color == “Purple”) then
hair_messy[4].isVisible = true
else
hair_messy[4].isVisible = false
end
if(tempHair == “Messy” and tempHair_Color == “Yellow”) then
hair_messy[5].isVisible = true
else
hair_messy[5].isVisible = false
end
if(tempHair == “Spikey” and tempHair_Color == “Blue”) then
hair_spike[1].isVisible = true
else
hair_spike[1].isVisible = false
end
if(tempHair == “Spikey” and tempHair_Color == “Brown”) then
hair_spike[2].isVisible = true
else
hair_spike[2].isVisible = false
end
if(tempHair == “Spikey” and tempHair_Color == “Midnight Blue”) then
hair_spike[3].isVisible = true
else
hair_spike[3].isVisible = false
end
if(tempHair == “Spikey” and tempHair_Color == “Purple”) then
hair_spike[4].isVisible = true
else
hair_spike[4].isVisible = false
end
if(tempHair == “Spikey” and tempHair_Color == “Yellow”) then
hair_spike[5].isVisible = true
else
hair_spike[5].isVisible = false
end
return tempHair
end
local hair_colorTitle = ui.newLabel{
bounds = { 0, 0, 88, 46 },
text = “Hair Color”,
font = “Algerian”,
textColor = { 200, 255, 255, 255 },
size = 18
}
localGroup:insert(hair_colorTitle)
if (deviceModel == “iPad”) then
hair_colorTitle.x = display.contentWidth * 0.585
else
hair_colorTitle.x = display.contentWidth * 0.62
end
hair_colorTitle.y = display.contentHeight * 0.57
hair_color = { [1] = “Blue”, [2] = “Brown”, [3] = “Midnight Blue”, [4] = “Purple”, [5] = “Yellow” }
local i = 1
local hair_colorText = ui.newLabel{
bounds = { 0, 0, 88, 46 },
text = hair_color[i],
font = “Algerian”,
textColor = { 255, 255, 255, 255 },
size = 28
}
localGroup:insert(hair_colorText)
if (deviceModel == “iPad”) then
hair_colorText.x = display.contentWidth * 0.585
else
hair_colorText.x = display.contentWidth * 0.62
end
hair_colorText.y = display.contentHeight * 0.47
local R_Arrow_Hair_Color = function( event )
i = i + 1
hair_colorText:setText(hair_color[i])
if(tempHair == “Messy” and hair_color[i] == “Blue”) then
hair_messy[1].isVisible = true
else
hair_messy[1].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Brown”) then
hair_messy[2].isVisible = true
else
hair_messy[2].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Midnight Blue”) then
hair_messy[3].isVisible = true
else
hair_messy[3].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Purple”) then
hair_messy[4].isVisible = true
else
hair_messy[4].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Yellow”) then
hair_messy[5].isVisible = true
else
hair_messy[5].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Blue”) then
hair_spike[1].isVisible = true
else
hair_spike[1].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Brown”) then
hair_spike[2].isVisible = true
else
hair_spike[2].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Midnight Blue”) then
hair_spike[3].isVisible = true
else
hair_spike[3].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Purple”) then
hair_spike[4].isVisible = true
else
hair_spike[4].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Yellow”) then
hair_spike[5].isVisible = true
else
hair_spike[5].isVisible = false
end
if i == 6 then
i = 1
hair_colorText:setText(hair_color[i])
if(tempHair == “Messy” and hair_color[i] == “Blue”) then
hair_messy[1].isVisible = true
else
hair_messy[1].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Brown”) then
hair_messy[2].isVisible = true
else
hair_messy[2].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Midnight Blue”) then
hair_messy[3].isVisible = true
else
hair_messy[3].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Purple”) then
hair_messy[4].isVisible = true
else
hair_messy[4].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Yellow”) then
hair_messy[5].isVisible = true
else
hair_messy[5].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Blue”) then
hair_spike[1].isVisible = true
else
hair_spike[1].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Brown”) then
hair_spike[2].isVisible = true
else
hair_spike[2].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Midnight Blue”) then
hair_spike[3].isVisible = true
else
hair_spike[3].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Purple”) then
hair_spike[4].isVisible = true
else
hair_spike[4].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Yellow”) then
hair_spike[5].isVisible = true
else
hair_spike[5].isVisible = false
end
end
tempHair_Color = hair_color[i]
return tempHair_Color
end
local L_Arrow_Hair_Color = function( event )
i = i - 1
hair_colorText:setText(hair_color[i])
if(tempHair == “Messy” and hair_color[i] == “Blue”) then
hair_messy[1].isVisible = true
else
hair_messy[1].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Brown”) then
hair_messy[2].isVisible = true
else
hair_messy[2].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Midnight Blue”) then
hair_messy[3].isVisible = true
else
hair_messy[3].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Purple”) then
hair_messy[4].isVisible = true
else
hair_messy[4].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Yellow”) then
hair_messy[5].isVisible = true
else
hair_messy[5].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Blue”) then
hair_spike[1].isVisible = true
else
hair_spike[1].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Brown”) then
hair_spike[2].isVisible = true
else
hair_spike[2].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Midnight Blue”) then
hair_spike[3].isVisible = true
else
hair_spike[3].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Purple”) then
hair_spike[4].isVisible = true
else
hair_spike[4].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Yellow”) then
hair_spike[5].isVisible = true
else
hair_spike[5].isVisible = false
end
if i == 0 then
i = 5
hair_colorText:setText(hair_color[i])
if(tempHair == “Messy” and hair_color[i] == “Blue”) then
hair_messy[1].isVisible = true
else
hair_messy[1].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Brown”) then
hair_messy[2].isVisible = true
else
hair_messy[2].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Midnight Blue”) then
hair_messy[3].isVisible = true
else
hair_messy[3].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Purple”) then
hair_messy[4].isVisible = true
else
hair_messy[4].isVisible = false
end
if(tempHair == “Messy” and hair_color[i] == “Yellow”) then
hair_messy[5].isVisible = true
else
hair_messy[5].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Blue”) then
hair_spike[1].isVisible = true
else
hair_spike[1].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Brown”) then
hair_spike[2].isVisible = true
else
hair_spike[2].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Midnight Blue”) then
hair_spike[3].isVisible = true
else
hair_spike[3].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Purple”) then
hair_spike[4].isVisible = true
else
hair_spike[4].isVisible = false
end
if(tempHair == “Spikey” and hair_color[i] == “Yellow”) then
hair_spike[5].isVisible = true
else
hair_spike[5].isVisible = false
end
end
tempHair_Color = hair_color[i]
return tempHair_Color
end
local faceTitle = ui.newLabel{
bounds = { 0, 0, 88, 46 },
text = “Face”,
font = “Algerian”,
textColor = { 200, 255, 255, 255 },
size = 18
}
localGroup:insert(faceTitle)
if (deviceModel == “iPad”) then
faceTitle.x = display.contentWidth * 0.585
else
faceTitle.x = display.contentWidth * 0.62
end
faceTitle.y = display.contentHeight * 0.73
face = { [1] = “Happy”, [2] = “Serious”, [3] = “Angry”, [4] = “Sad” }
local i = 1
local faceText = ui.newLabel{
bounds = { 0, 0, 88, 46 },
text = face[i],
font = “Algerian”,
textColor = { 255, 255, 255, 255 },
size = 28
}
localGroup:insert(faceText)
if (deviceModel == “iPad”) then
faceText.x = display.contentWidth * 0.585
else
faceText.x = display.contentWidth * 0.62
end
faceText.y = display.contentHeight * 0.63
local R_Arrow_Face = function( event )
i = i + 1
faceText:setText(face[i])
if i == 5 then
i = 1
faceText:setText(face[i])
end
tempFace = face[i]
return tempFace
end
local L_Arrow_Face = function( event )
i = i - 1
faceText:setText(face[i])
if i == 0 then
i = 4
faceText:setText(face[i])
end
tempFace = face[i]
return tempFace
end
local button_next = function( event )
–[[ For debugging submitted information
print(tempName)
print(tempRace)
print(tempHair)
print(tempHair_Color)
print(tempFace)–]]
playerData = { [1] = tempName , [2] = tempRace, [3] = tempHair, [4] = tempHair_Color, [5] = tempFace}
for i = 1, 5, 1 do
–print(playerData[i])
end
local counter = 0
for row in db:nrows(“SELECT id FROM playerCharData”) do
print(row.id)
aRow = row.id
counter = counter + 1
end
local playerDataFill =[[INSERT INTO playerCharData VALUES (NULL, ‘]]…playerData[1]…[[’,’]]…playerData[2]…[[’,’]]…playerData[3]…[[’,’]]…playerData[4]…[[’,’]]…playerData[5]…[[’, “Squire”, 1);]]
if (counter < 3) then
db:exec( playerDataFill )
end
end
function changeScene(e)
if(e.phase == “ended”) then
director:changeScene(e.target.scene, “moveFromLeft”)
end
end
local button_back = ui.newButton
{
defaultSrc = “BoH_CG_ButtonUp.png”,
defaultX = 132,
defaultY =37,
overSrc = “BoH_CG_ButtonDown.png”,
overX = 132,
overY = 37,
onRelease = button_back,
id = “button_back”,
text = “Back”,
font = “Algerian”,
size = 28,
offset = 3
}
button_back.scene = “menu”
localGroup:insert(button_back)
button_back:addEventListener(“touch”, changeScene)
if (deviceModel == “iPad”) then
button_back.x = display.contentWidth * .52
else
button_back.x = display.contentWidth * .54
end
button_back.y = display.contentHeight - 25
local button_next = ui.newButton
{
defaultSrc = “BoH_CG_ButtonUp.png”,
defaultX = 132,
defaultY =37,
overSrc = “BoH_CG_ButtonDown.png”,
overX = 132,
overY = 37,
onRelease = button_next,
id = “button_next”,
text = “Next”,
font = “Algerian”,
size = 28,
offset = 3
}
localGroup:insert(button_next)
if (deviceModel == “iPad”) then
button_next.x = display.contentWidth * .8
else
button_next.x = display.contentWidth * .83
end
button_next.y = display.contentHeight - 25
local L_Arrow_Race = ui.newButton
{
defaultSrc = “BoH_CG_Arrow_L_Up.png”,
defaultX = 22,
defaultY =29,
overSrc = “BoH_CG_Arrow_L_Down.png”,
overX = 22,
overY = 29,
onRelease = L_Arrow_Race,
id = “L_Arrow_Race”
}
localGroup:insert(L_Arrow_Race)
if (deviceModel == “iPad”) then
L_Arrow_Race.x = display.contentWidth * .45
else
L_Arrow_Race.x = display.contentWidth * .45
end
L_Arrow_Race.y = display.contentHeight * .2
local L_Arrow_Hair = ui.newButton
{
defaultSrc = “BoH_CG_Arrow_L_Up.png”,
defaultX = 22,
defaultY =29,
overSrc = “BoH_CG_Arrow_L_Down.png”,
overX = 22,
overY = 29,
onRelease = L_Arrow_Hair,
id = “L_Arrow_Hair”
}
localGroup:insert(L_Arrow_Hair)
if (deviceModel == “iPad”) then
L_Arrow_Hair.x = display.contentWidth * .45
else
L_Arrow_Hair.x = display.contentWidth * .45
end
L_Arrow_Hair.y = display.contentHeight * .36
local L_Arrow_Hair_Color = ui.newButton
{
defaultSrc = “BoH_CG_Arrow_L_Up.png”,
defaultX = 22,
defaultY =29,
overSrc = “BoH_CG_Arrow_L_Down.png”,
overX = 22,
overY = 29,
onRelease = L_Arrow_Hair_Color,
id = “L_Arrow_Hair_Color”
}
localGroup:insert(L_Arrow_Hair_Color)
if (deviceModel == “iPad”) then
L_Arrow_Hair_Color.x = display.contentWidth * .45
else
L_Arrow_Hair_Color.x = display.contentWidth * .45
end
L_Arrow_Hair_Color.y = display.contentHeight * .52
local L_Arrow_Face = ui.newButton
{
defaultSrc = “BoH_CG_Arrow_L_Up.png”,
defaultX = 22,
defaultY =29,
overSrc = “BoH_CG_Arrow_L_Down.png”,
overX = 22,
overY = 29,
onRelease = L_Arrow_Face,
id = “L_Arrow_Face”
}
localGroup:insert(L_Arrow_Face)
if (deviceModel == “iPad”) then
L_Arrow_Face.x = display.contentWidth * .45
else
L_Arrow_Face.x = display.contentWidth * .45
end
L_Arrow_Face.y = display.contentHeight * .68
local R_Arrow_Race = ui.newButton
{
defaultSrc = “BoH_CG_Arrow_R_Up.png”,
defaultX = 22,
defaultY =29,
overSrc = “BoH_CG_Arrow_R_Down.png”,
overX = 22,
overY = 29,
onRelease = R_Arrow_Race,
id = “R_Arrow_Race”
}
localGroup:insert(R_Arrow_Race)
if (deviceModel == “iPad”) then
R_Arrow_Race.x = display.contentWidth * .9
else
R_Arrow_Race.x = display.contentWidth * .96
end
R_Arrow_Race.y = display.contentHeight * .2
local R_Arrow_Hair = ui.newButton
{
defaultSrc = “BoH_CG_Arrow_R_Up.png”,
defaultX = 22,
defaultY =29,
overSrc = “BoH_CG_Arrow_R_Down.png”,
overX = 22,
overY = 29,
onRelease = R_Arrow_Hair,
id = “R_Arrow_Hair”
}
localGroup:insert(R_Arrow_Hair)
if (deviceModel == “iPad”) then
R_Arrow_Hair.x = display.contentWidth * .9
else
R_Arrow_Hair.x = display.contentWidth * .96
end
R_Arrow_Hair.y = display.contentHeight * .36
local R_Arrow_Hair_Color = ui.newButton
{
defaultSrc = “BoH_CG_Arrow_R_Up.png”,
defaultX = 22,
defaultY =29,
overSrc = “BoH_CG_Arrow_R_Down.png”,
overX = 22,
overY = 29,
onRelease = R_Arrow_Hair_Color,
id = “R_Arrow_Hair_Color”
}
localGroup:insert(R_Arrow_Hair_Color)
if (deviceModel == “iPad”) then
R_Arrow_Hair_Color.x = display.contentWidth * .9
else
R_Arrow_Hair_Color.x = display.contentWidth * .96
end
R_Arrow_Hair_Color.y = display.contentHeight * .52
local R_Arrow_Face = ui.newButton
{
defaultSrc = “BoH_CG_Arrow_R_Up.png”,
defaultX = 22,
defaultY =29,
overSrc = “BoH_CG_Arrow_R_Down.png”,
overX = 22,
overY = 29,
onRelease = R_Arrow_Face,
id = “R_Arrow_Face”
}
localGroup:insert(R_Arrow_Face)
if (deviceModel == “iPad”) then
R_Arrow_Face.x = display.contentWidth * .9
else
R_Arrow_Face.x = display.contentWidth * .96
end
R_Arrow_Face.y = display.contentHeight * .68
local nameField
local function fieldHandler( getObj )
return function( event )
if (“began” == event.phase) then
elseif (“ended” == event.phase) then
native.setKeyboardFocus ( nil )
elseif (“submitted” == event.phase) then
native.setKeyboardFocus ( nil )
tempName = nameField.text
return tempName
end
end
end
nameField = native.newTextField(0, 0, 200, 20, fieldHandler( function() return nameField end))
nameField.font = native.newFont ( “Algerian”, 40)
nameField.align = “center”
nameField.text = “Name”
localGroup:insert(nameField)
if (deviceModel == “iPad”) then
nameField.x = display.contentWidth * .675
else
nameField.x = display.contentWidth * .705
end
nameField.y = display.contentHeight * .1
– MUST return a display.newGroup()
return localGroup
end[/lua] [import]uid: 74407 topic_id: 20762 reply_id: 81742[/import]