photon.*

Type library
Revision 2017.3179
Keywords photon
Platforms Android, iOS, macOS, Windows

Overview

Photon is a multiplayer-game development framework that is fast, lean and flexible.

Photon consists of a server and client SDKs for all major platforms. The Photon Cloud is a fully managed service of Photon Servers. Exit Games is running them in several regions, ready to use instantly.

This Corona Photon Plugin provides a simple-to-use Lua API to find games, communicate with other clients through Photon Cloud or Photon Server, and a lot more.

Syntax

local photon = require "plugin.photon"
local masterAddress = "app-eu.exitgameslcoud.com:5055" -- using Photon Cloud EU region as default
local appId = "" -- each application on the Photon Cloud gets an appId
local appVersion = "1.0" -- clients with different versions will be separated (easy to update clients)
local client = photon.loadbalancing.LoadBalancingClient.new(masterAddress, appId, appVersion)
client:connect()

Modules

Project Settings

To use this plugin, add an entry into the plugins table of build.settings. When added, the build server will integrate the plugin during the build phase.

settings =
{
    plugins =
    {
        ["plugin.photon"] =
        {
            publisherId = "com.exitgames",
        },
    },
}

Corona Native

Using Corona Photon Plugin in a Corona Native project can reduce time which client spends on establishing connection to the server (with encryption enabled for authentication phase). Download plugin library for your platform and link it into app executable.

iOS

Sample Code

The Basic Sample is a simple app that demonstrates creation of the room and events exchange in the room.

The Particle Demo automatically joins players into a room, where it syncs the players' positions on a grid. It also uses some advanced features like properties, event caching and it splits the "world" grid into four Interest Groups.

The Chat API Demo is a chat client sample.

Note: The samples are Photon Cloud enabled - no need to setup any server! Register (for free), check your mail to access the Photon Cloud Dashboard and copy and paste your AppID into the AppId field in cloud-app-info.lua.

Support