[Resolved] Class Project

So I am in class and am trying to figure out how to do a certain animation on my project. We are making a CRAPS game and I want the die to randomly switch sides to the background music until the music stops to show that the die are done and you get your result. I cannot figure it out how to do so. Could you guys please help?
here is my code. the song is about 7 seconds
os.execute (“cls”)

display.setStatusBar (display.HiddenStatusBar)

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 Rollcount = 0

local Roll = display.newImage (“roll.png”)
Roll.y = 280
Roll.x = 250

local d1s1 = display.newImage (“1.png”)
d1s1.y = 160
d1s1.x = 100

local d1s2 = display.newImage (“2.png”)
d1s2.y = 160
d1s2.x = 100

local d1s3 = display.newImage (“3.png”)
d1s3.y = 160
d1s3.x = 100

local d1s4 = display.newImage (“4.png”)
d1s4.y = 160
d1s4.x = 100

local d1s5 = display.newImage (“5.png”)
d1s5.y = 160
d1s5.x = 100

local d1s6 = display.newImage (“6.png”)
d1s6.y = 160
d1s6.x = 100

local d2s1 = display.newImage (“1.png”)
d2s1.y = 160
d2s1.x = 380

local d2s2 = display.newImage (“2.png”)
d2s2.y = 160
d2s2.x = 380

local d2s3 = display.newImage (“3.png”)
d2s3.y = 160
d2s3.x = 380

local d2s4 = display.newImage (“4.png”)
d2s4.y = 160
d2s4.x = 380

local d2s5 = display.newImage (“5.png”)
d2s5.y = 160
d2s5.x = 380

local d2s6 = display.newImage (“6.png”)
d2s6.y = 160
d2s6.x = 380

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: 24880 reply_id: 324880[/import]

Hi CeroLobo,

Please use < lua > and < /lua > tags when you post code, it makes it readable.

For your dice, check out this tutorial, it uses a timer but you could tie it to the music stopping instead; http://techority.com/2011/11/22/rolling-the-dice/

I think it will prove a lot simpler than the above :slight_smile:

Peach [import]uid: 52491 topic_id: 24880 reply_id: 100952[/import]

WOW! You are AMAZING thank you so much that really helped. In our class we never used sprites and now that I know a little about them it’s going to help. Thank you again! [import]uid: 129092 topic_id: 24880 reply_id: 101117[/import]

No worries at all.

I know sprites can be a little confusing at first but they are so incredibly useful once you have a basic understanding of how they work.

Good luck with the rest of your project!

Peach :slight_smile: [import]uid: 52491 topic_id: 24880 reply_id: 101178[/import]