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 928

Methods

getCustomProperties() → {object}

Returns custom properties.

Source:
  • Photon-Javascript_SDK.js, line 1075
Returns:
Custom properties.
Type
object

getCustomProperty(name) → {object}

Returns custom property by name.

Parameters:
Name Type Description
name string Name of the property.
Source:
  • Photon-Javascript_SDK.js, line 1001
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 1008
Returns:
Property or default value if property not found.
Type
object

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 944
Returns:
Actor's room.
Type
Photon.LoadBalancing.Room

isSuspended() → {boolean}

Returns true if actor is in suspended state.

Source:
  • Photon-Javascript_SDK.js, line 1058
Returns:
Actor suspend state.
Type
boolean

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 993

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 950

setCustomProperties(properties, webForward, expectedProperties)

Sets custom properties.

Parameters:
Name Type Argument Default Description
properties object Table of properties to set.
webForward boolean <optional>
false Forward to web hook.
expectedProperties object <optional>
Table of properties expected when update occurs. (CAS : "Check And Swap")
Source:
  • Photon-Javascript_SDK.js, line 1039

setCustomProperty(name, value, webForward, expectedValue)

Sets custom property.

Parameters:
Name Type Argument Default Description
name string Name of the property.
value object Property value.
webForward boolean <optional>
false Forward to web hook.
expectedValue object <optional>
Property value expected when update occurs. (CAS : "Check And Swap")
Source:
  • Photon-Javascript_SDK.js, line 1016

setName(name)

Sets actor name.

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