Basica Flashcards
How do you load audio?
–Preload audio
Local soundName = audio.loadsound(“sound file “)
How to make images a variable
Local variableName = display.newImage(“fileName”)
How to display image in the center
ImageName.x = centerX ImageName.Y = centerY
How do you display a new image
Display.newImage(“fileName”)
How to change position on screen
transition.to(background, { time= 2000, y=centerY, x=centerX})
How to transition opacity
transition.to(ImageName, {alpha=1})
How to transition to scale
transition.to( ImageName, { xScale= 2, yScale= 2 })
How to change image size
Image.xScale=
image.yScale=
How to start image off screen
ImageName.y = display.contentHeight + 60
How to change image opacity
ImageName.alpha = 2
OnComplete does what?
Once something happens this cause something else to happen. It’s like an if statement.
Add text
Local text = display.text(“ your text” x axis, y axis, font type, font size)
Change text opacity
Text.alpha = .5
Rotate text
Text.rotation=
Set text color
Text:setTextColor(R,G,B)
Have an item leave the screen
Display.remove(event.target)
Example text in attack of cuteness
Local function goAway(event) Display.remove(event.target) Text= nil Display.remove spawnEnemy
Display score
ScoreText = display.newText (“Score 0” , 0,0 “ font type, font size)
ScoreText.x = centerX ScoreText.y = 10 Score = 0 ( will reset score to zero if you start a new game)
How to play a sound
Audio.play(soundName)
Return true
Find out
Set up forward references
Used to reference items used later.lua needs to know what it’s using