Class: Actor

Photon.LoadBalancing. Actor

Summarizes a "player" within a room, identified (in that room) by ID (or "actorNr"). Extend to implement custom logic.

new Actor(name, actorNr, isLocal)

Parameters:
Name Type Description
name string Actor name.
actorNr number Actor ID.
isLocal boolean Actor is local.
Source:
  • Photon-Javascript_SDK.js, line 1756

Methods

getCustomProperty(name) → {object}

Returns custom property by name.

Parameters:
Name Type Description
name string Name of the property.
Source:
  • Photon-Javascript_SDK.js, line 1819
Returns:
Property or undefined if property not found.
Type
object

getCustomPropertyOrElse(name, defaultValue) → {object}

Returns custom property by name or default value.

Parameters:
Name Type Description
name string Name of the property.
defaultValue object Default property value.
Source:
  • Photon-Javascript_SDK.js, line 1829
Returns:
Property or default value if property not found.
Type
object

getJoinToken() → {string}

For local actor, returns join token automatically saved after last room join.

Source:
  • Photon-Javascript_SDK.js, line 1873
Returns:
Join token.
Type
string

getRoom() → {Photon.LoadBalancing.Room}

Actor's room: the room initialized by client for create room operation or room client connected to.

Source:
  • Photon-Javascript_SDK.js, line 1771
Returns:
Actor's room.
Type
Photon.LoadBalancing.Room

onPropertiesChange(changedCustomProps, byClient)

Called on every actor properties update: properties set by client, poperties update from server. Override to update custom room state.

Parameters:
Name Type Argument Description
changedCustomProps object Key-value map of changed properties.
byClient boolean <optional>
true if properties set by client.
Source:
  • Photon-Javascript_SDK.js, line 1809

raiseEvent(eventCode, data, options)

Raises game custom event.

Parameters:
Name Type Argument Description
eventCode number Identifies this type of event (and the content). Your game's event codes can start with 0.
data object <optional>
Custom data you want to send along (use null, if none).
options object <optional>
Additional options
Properties:
Name Type Description
options object Additional options
Properties
Name Type Argument Default Description
interestGroup number <optional>
The ID of the interest group this event goes to (exclusively).
cache Photon.LoadBalancing.Constants.EventCaching <optional>
EventCaching.DoNotCache Events can be cached (merged and removed) for players joining later on.
receivers Photon.LoadBalancing.Constants.ReceiverGroup <optional>
ReceiverGroup.Others Defines to which group of players the event is passed on.
targetActors number[] <optional>
Defines the target players who should receive the event (use only for small target groups).
webForward boolean <optional>
false Forward to web hook.
Source:
  • Photon-Javascript_SDK.js, line 1780

setCustomProperties(properties)

Sets custom properties.

Parameters:
Name Type Description
properties object Table of properties to set.
Source:
  • Photon-Javascript_SDK.js, line 1856

setCustomProperty(name, value)

Sets custom property.

Parameters:
Name Type Description
name string Name of the property.
value object Property value.
Source:
  • Photon-Javascript_SDK.js, line 1840

setName(name)

Sets actor name.

Parameters:
Name Type Description
name string Actor name.
Source:
  • Photon-Javascript_SDK.js, line 1799