OK, so I am trying to figure out this whole getting a sprite or image to appear once something happens. In this case I need the images or sprites to appear once the sum of the dice is figured out. Can anyone help me out?
main.lua
[lua]os.execute (“cls”)
display.setStatusBar (display.HiddenStatusBar)
require “sprite”
local bckgrnd = display.newRect (0, 0, 480, 320)
bckgrnd.y = 160
bckgrnd.x = 240
bckgrnd:setFillColor (20, 124, 12)
local table = display.newImage (“craps.2.png”)
table.y = 170
local diceTotal = 0
local canRoll = true
local diceSheet = sprite.newSpriteSheet( “Dice3.png”, 64, 64)
local Roll = display.newImage (“roll.png”)
Roll.y = 280
Roll.x = 250
local diceSet = sprite.newSpriteSet (diceSheet, 1, 6 )
sprite.add( diceSet, “Dice1”, 1, 6, 195, 0)
sprite.add( diceSet, “Dice2”, 1, 6, 210, 0)
local dice = sprite.newSprite( diceSet )
dice.x = 100
dice.y =185
dice:prepare(“Dice1”)
local dice2 = sprite.newSprite( diceSet )
dice2.x = 350
dice2.y = 85
dice:prepare(“Dice2”)
local two = display.newImage (“casino#2.png”)
two.x = 225
two.y = 150
two.isVisible = false
local three = display.newImage (“casino#3.png”)
three.x = 225
three.y = 150
three.isVisible = false
local four = display.newImage (“casino#4.png”)
four.x = 225
four.y = 150
four.isVisible = false
local five = display.newImage (“casino#5.png”)
five.x = 225
five.y = 150
five.isVisible = false
local six = display.newImage (“casino#6.png”)
six.x = 225
six.y = 150
six.isVisible = false
local seven = display.newImage (“casino#7.png”)
seven.x = 225
seven.y = 150
seven.isVisible = false
local eight = display.newImage (“casino#8.png”)
eight.x = 225
eight.y = 150
eight.isVisible = false
local nine = display.newImage (“casino#9.png”)
nine.x = 225
nine.y = 150
nine.isVisible = false
local ten = display.newImage (“casino#10.png”)
ten.x = 225
ten.y = 150
ten.isVisible = false
local eleven = display.newImage (“casino#11.png”)
eleven.x = 225
eleven.y = 150
eleven.isVisible = false
local twelve = display.newImage (“casino#12.png”)
twelve.x = 225
twelve.y = 150
twelve.isVisible = false
–End Roll Function
local function endRoll()
dice:pause()
dice2:pause()
diceTotal = dice.currentFrame + dice2.currentFrame
print(diceTotal) --Print the result in the terminal
canRoll = true --Allow the dice to be rolled again
end
–Roll function
local function rollDice()
if canRoll == true then
canRoll = false --Prevent dice from being rolled again before the current role is over
dice:play()
dice2:play()
randomTime = math.random(6000, 6000)
timer.performWithDelay(randomTime, endRoll, 1)
end
end
Roll:addEventListener(“tap”, rollDice)
local RollMusic_mp3 = audio.loadStream (“Music Super Mario Kart - Item Box (Ding, Ding).mp3”)
function Roll:tap (event)
audio.play (RollMusic_mp3)
end
Roll:addEventListener (‘tap’, Roll) [import]uid: 129092 topic_id: 24920 reply_id: 324920[/import]