Game Development Reference
In-Depth Information
Displaying Video
If you want to play a video on the iOS device—for example, as an intro or a lead-in to a level in a
game—you can use the MOAIMoviePlayer class. To play the movie, you need to initialize it with the
path to the movie and then invoke the play function:
MOAIMoviePlayer.init (
" http://km.support.apple.com/library/APPLE/APPLECARE_ALLGEOS/HT1211/sample_iTunes.mov " )
MOAIMoviePlayer.play ()
Device Orientation
EVENT_RESIZE event is triggered. We can listen for
MOAIGfxDevice class.
viewport:setSize(width, height)
viewport:setScale(width, height)
In some scenarios, you might want to notify the user with some information—for example, when a
task is complete (e.g., when the crops are ready to be harvested in a Farmville-type application).
To enable you to do this, Moai has a MOAINotifications class that needs a listener to be added
listening to the events. The code below has three distinct portions. onRegComplete is called when we
try to register for a remote notification; it also informs us if it was successful or if it failed. The other
function displays the notification when it occurs, based on the data passed. And the last bit sets up
and registers the notification.
function onRegComplete(code, token)
print("Registered")
if code==MOAINotification.REMOTE_NOTIFICATION_RESULT_REGISTERED then
print("Registered " .. token)
elseif code==MOAINotification.REMOTE_NOTIFICATION_RESULT_UNREGISTERED then
else
print("Registration failed")
end
end
function onRemoteNotification(event)
print("Notification received")
message = event.aps.alert
 
Search WWH ::




Custom Search