Game Development Reference
In-Depth Information
decreaseVolume from our app. Since these can be written for any framework, our code will be quite
portable. One of the basic mistakes a lot of developers (especially those starting off) make is that of
directly accessing the framework functions. Due to the fact that the code becomes tightly integrated
with the framework, it becomes difficult to port it.
Working with Videos
We have just had a look at how to work with sound; let's look at how to work with video. The media
namespace has an easy-to-use API and makes it quite simple to play video:
function done(event)
print( "The video has finished playing" )
playVideo function is
showControls , indicates
false will disable the display of this interface.
the video will be run while the video is being played. So you might want to pause everything and wait
for the video to finish playing and then resume execution. You would want to do this, for example,
when you play an intro video at the start of a game and you didn't want the game to start playing till
the video finished playing.
Corona SDK has another video-playing API, which is not cross-platform, but allows for advanced
manipulation on the iOS platform. This is available as native.newVideo .
The objects created via this API can be rotated, assigned as a physics body, and manipulated as a
display object.
local video = native.newVideo ( 0, 0, 160, 240 )
--
function theHandler( event )
print(event.phase, event.errorCode)
end
--
video:load ( "theVideo.mov", system.ResourceDirectory )
video:addEventListener( "video", theHandler )
video:play()
Note This function might not be available as a public release yet, so if you have a trial version of Corona SDK,
you might not be able to run this particular code.
 
 
Search WWH ::




Custom Search