We can use audio.setVolume() for setting the volume either for a specific channel or setting the master volume.
Syntax:
audio.setVolume( volume [, { [channel=c] } ] )
Example:
audio.setVolume( 0.75, { channel=1 } ) --set the volume on channel 1
corona sdk for iphone/Android
We can use audio.setVolume() for setting the volume either for a specific channel or setting the master volume.
Syntax:
audio.setVolume( volume [, { [channel=c] } ] )
Example:
audio.setVolume( 0.75, { channel=1 } ) --set the volume on channel 1
Description:
Returns the number of children in a group. You access the children by integer index.
Syntax:
value = group.numChildren
Example:
local group = display.newGroup() group:insert( rect1 ) -- assume rect1 is an existing display object group:insert( rect2 ) -- assume rect2 is an existing display object for i=1,group.numChildren do local child = group[i] local description = (child.isVisible and "visible") or "not visible" print( "child["..i.."] is " .. description ) end
Sets the x,y components of the global gravity vector, in units of m/s2. The default is ( 0, 9.8 ) to simulate standard Earth gravity, pointing downwards on the y-axis.
syntax
physics.setGravity(gx,gy)
gx
Sets the global gravity vector in X direction, in units of m/s2.
gy
Sets the global gravity vector in Y direction, in units of m/s2.
str = str:gsub("^%l", string.upper)
–Show a basic white bar
local timeBar = display.newRect( 20, 165, 280, 20 ) timeBar:setReferencePoint(display.BottomLeftReferencePoint) timeBar.x = 20 timeBar.y = 165
–Make the bar shrink over time
local function loseTime (event) timeBar.width = timeBar.width - 2 timeBar:setReferencePoint(display.BottomLeftReferencePoint) timeBar.x = 20 end gameTimer = timer.performWithDelay(100,loseTime, 0)
1) Moving background
—————————————————–
local paper = display.newImage("paper.png")
paper:setReferencePoint(display.CenterLeftReferencePoint)
paper.x = 0
paper.y = 0
local paper2 = display.newImage("paper.png")
paper2:setReferencePoint(display.CenterLeftReferencePoint)
paper2.x = 0
paper2.y = 480
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time
local yOffset = ( 0.15 * tDelta )
paper.y = paper.y - yOffset
paper2.y = paper2.y - yOffset
if (paper.y + paper.contentHeight-240) < 480 then
paper:translate( 0, 480 * 2)
end
if (paper2.y + paper2.contentHeight-240) < 480 then
paper2:translate(0, 480 * 2)
end
end
Runtime:addEventListener( "enterFrame", move )
———————————————————————–
Syntax: sprite.add( spriteSet, sequenceName, startFrame, frameCount, time, [loopParam] ) Example:
local sheet1 = sprite.newSpriteSheet( "runningcat.png", 512, 256 ) local spriteSet1 = sprite.newSpriteSet(sheet1, 1,sprite.add( spriteSet1, "cat", 1, 8, 1000, 0 ) -- play 8 frames every 1000 ms local instance1 = sprite.newSprite( spriteSet1 ) instance1:prepare("cat") instance1:play()