1. Home
  2. /
  3. Solar2d
  4. /
  5. Lua Example - Audio Play

Lua Example - Audio Play - Solar2d Typing CST Test

Loading…

Lua Example - Audio Play — Solar2d Code

Plays a sound effect when a rectangle is tapped.

-- main.lua
local sound = audio.loadSound("click.wav")
local rect = display.newRect(display.contentCenterX, display.contentCenterY, 150, 80)
rect:setFillColor(1, 0.5, 0)

local function playSound()
	audio.play(sound)
end

rect:addEventListener("tap", playSound)

Solar2d Language Guide

Solar2D (formerly Corona SDK) is a free, open-source, cross-platform 2D game and app development framework using Lua scripting. It focuses on rapid development and performance for mobile, desktop, and HTML5 applications.

Primary Use Cases

  • ▸2D mobile games
  • ▸Educational apps and interactive media
  • ▸Prototyping and game jams
  • ▸Casual games for iOS/Android
  • ▸HTML5 browser-based apps

Notable Features

  • ▸Lua scripting for all game/app logic
  • ▸Fast 2D rendering with hardware acceleration
  • ▸Physics engine integration (Box2D)
  • ▸Cross-platform support (iOS, Android, Windows, macOS, HTML5)
  • ▸Extensive plugin ecosystem for ads, analytics, and native features

Origin & Creator

Originally developed as Corona SDK by Ansca Mobile in 2009, it was later renamed Solar2D and made open-source in 2020.

Industrial Note

Solar2D is popular for rapid 2D mobile development, small-scale games, casual apps, and educational tools where lightweight Lua scripting and cross-platform deployment are valued.

More Solar2d Typing Exercises

Solar2D Lua Example - Simple CounterSolar2D Lua Example - Moving ObjectSolar2D Lua Example - Touch DragSolar2D Lua Example - Simple ButtonSolar2D Lua Example - Fade In/OutSolar2D Lua Example - Simple PhysicsSolar2D Lua Example - Sprite AnimationSolar2D Lua Example - Timer EventSolar2D Lua Example - Simple Scene

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher