Namespaces

Classes

Match
Signal
WebDialog

Namespaces

Cocoon
Cocoon
Ad
AdMob
Banner
Chartboost
Heyzap
Interstitial
MoPub
App
Device
Dialog
InApp
Motion
Multiplayer
GameCenter
GooglePlayGames
LoopbackService
Notification
Local
Parse
Proxify
Share
Social
Facebook
GameCenter
GooglePlayGames
Interface
Touch
Utils
WebView
Widget

Events

On click

Triggered when a banner is clicked.

Example
banner.on("click", function(){
   console.log("Banner clicked");
});

On dismiss

Triggered when a banner is collapsed.

Example
banner.on("dismiss", function(){
   console.log("Banner dismissed the modal content");
});

On fail

Triggered when the loading process of a banner has failed.

Example
banner.on("fail", function(error){
   console.log("Banner failed to load: " + JSON.stringify(error));
});

On load

Triggered when a new banner is loaded.

Example
banner.on("load", function(){
   console.log("Banner loaded " + banner.width, banner.height);
});

On show

Triggered when a new banner is expanded to full screen.

Example
banner.on("show", function(){
   console.log("Banner shown a modal content");
});

On click

Triggered when an interstitial is clicked.

Example
interstitial.on("click", function(){
   console.log("Interstitial clicked");
});

On dismiss

Triggered when an interstitial is closed.

Example
interstitial.on("dimissed", function(){
   console.log("Interstitial dimissed");
});

On fail

Triggered when the loading process of an interstitial has failed.

Example
interstitial.on("fail", function(error){
   console.log("Interstitial failed to load: " + JSON.stringify(error));
});

On load

Triggered when a new interstitial is loaded.

Example
banner.on("load", function(){
   console.log("Interstitial loaded");
});

On reward

Triggered when an video reward is completed.

Example
interstitial.on("reward", function(reward, error){
  if (reward && reward.amount > 0) {
    console.log("Reward completed. Earned " + reward.amount + " items");
  }
});

On show

Triggered when a new interstitial is shown.

Example
interstitial.on("show", function(){
   console.log("Interstitial shown");
});

On application activated

Allows to listen to events called when the application is activated. The callback function does not receive any parameter.

Example
Cocoon.App.on("activated", function(){
 ...
});

On application suspended

Allows to listen to events called when the application is suspended. The callback function does not receive any parameter.

Example
Cocoon.App.on("suspended", function(){
 ...
});

On application suspending

Allows to listen to events called when the application is suspending. The callback function does not receive any parameter.

Example
Cocoon.App.on("suspending", function(){
 ...
});

On memory warning

Allows to listen to memory warning notifications from the system It is strongly recommended that you implement this method and free up as much memory as possible by disposing of cached data objects, images on canvases that can be recreated.

Example
Cocoon.App.on("memorywarning", function(){
 ...
});

On purchase

Allows to listen to events about the purchasing process.

  • The callback 'start' receives a parameter the product id of the product being purchased when the purchase of a product starts.
  • The callback 'complete' receives as parameter the Cocoon.InApp.PurchaseInfo object of the product being purchased when the purchase of a product is completed.
  • The callback 'error' receives a parameters the product id and an error message when the purchase of a product fails.
Example
Cocoon.InApp.on("purchase", {
   start: function(productId) {
       console.log("purchase started " + productId);
   },
   error: function(productId, error) {
       console.log("purchase failed " + productId + " error: " + JSON.stringify(error));
   },
   complete: function(purchase) {
       console.log("purchase completed " + JSON.stringify(purchase));
   }
});

On invitation

Triggered when an invitation is received and loaded. This listener should be setup first thing even before the init is called.

Example
multiplayerService.on("invitation", {
  received: function() {
      console.log("Invitation received");
  },
  loaded: function(match, error) {
      console.log("Invitation ready: (Error: + " + JSON.stringify(error) + ")");
  }
});

On restore products callbacks

Allows to listen to events about the restoring process.

  • The callback 'dataReceived'
  • The callback 'stateChanged'
  • The callback 'connectionWithPlayerFailed' allows listening to events called when a netowrk connection with a player fails
  • The callback 'failed' allows listening to events called when the match fails.
Example
match.on("match",{
 dataReceived: function(match, data, playerId){ ... },
 stateChanged: function(match, playerId, connectionState){ ... },
 connectionWithPlayerFailed: function(match, playerId, errorMsg){ ... }
 failed: function(match, errorMsg){ ... }
});

On notification

Allows to listen to events when the application receives a notification.

Example
Cocoon.Notification.Local.on("notification", function(data) {
     console.log('Local notification received: ' + JSON.stringify(data));
});
Cocoon.Notification.Parse.on("notification", function(data) {
     console.log('Remote notification received: ' + JSON.stringify(data));
});

On loginStatusChanged

Triggered when the user's login status has changed.

Example
socialAPI.on("loginStatusChanged", function(loggedIn){
   console.log("User logged in?: " + loggedIn);
});
Atomic Plugins - JavaScript Documentation by Ludei, DocStrap Copyright © 2012-2013
The contributors to the JSDoc3 and DocStrap projects.