Class: NetworkObject2D

Grape2D. NetworkObject2D

new NetworkObject2D(options)

This specifies an Grape2D.Object2D that is to be transmitted to the client or server, at any time.
Parameters:
Name Type Argument Description
options Object <optional>
Setup options. See Grape2D.Object2D.
Properties
Name Type Description
id number | string Object unique identifier.
Source:

Extends

Members

<private> boundingBox :Grape2D.Shape

Object's bounding box.
Type:
Inherited From:
Source:

<private> boundingBoxOffset :Grape2D.Vector

Bounding box offset.
Type:
Inherited From:
Source:

<private> castShadow :boolean

Object cast shadow.
Type:
  • boolean
Inherited From:
Source:

<private> position :Grape2D.Vector

Object's position.
Type:
Inherited From:
Source:

<private> receiveLight :boolean

Object can receive light.
Type:
  • boolean
Inherited From:
Source:

<private> texture :Grape2D.Texture

The texture of the object.
Type:
Inherited From:
Source:

<private> textureOffset :Grape2D.Vector

The offset of the texture.
Type:
Inherited From:
Source:

<private> texturePosition :Grape2D.Vector

The position of the texture. It is computed from the object's position and the texture offset.
Type:
Inherited From:
Source:

<private> visible :boolean

Visible property.
Type:
  • boolean
Inherited From:
Source:

Methods

canCastShadow() → {boolean}

Checks if the object can cast shadows.
Inherited From:
Source:
Returns:
True if it cast shadows, false otherwise.
Type
boolean

canReceiveLight() → {boolean}

Checks if an object can receive light.
Inherited From:
Source:
Returns:
True if it receives light.
Type
boolean

<protected> computeBoundingBoxPosition()

Computes the bounding box position, from the object's position and bounding box offset.
Inherited From:
Source:

<protected> computeTexturePosition()

Computes the texture position of the object, from the object's position and texture offset.
Inherited From:
Source:

createNetworkClone() → {Grape2D.SnapshotNetworkObject2D}

Creates a clone object to be passed through the network.
Source:
Returns:
Network clone.
Type
Grape2D.SnapshotNetworkObject2D

getBoundingBox() → {Grape2D.Shape}

Gets the bounding box of the object.
Inherited From:
Source:
Returns:
The shape of the object.
Type
Grape2D.Shape

getBoundingBoxOffset() → {Grape2D.Vector}

Gets the bounding box offset
Inherited From:
Source:
Returns:
The bounding box offset.
Type
Grape2D.Vector

getBoundingBoxPosition() → {Grape2D.Vector}

Gets the bounding box position.
Inherited From:
Source:
Returns:
The center position of the bounding box.
Type
Grape2D.Vector

getId() → {number|string}

Gets the object's id.
Source:
Returns:
Object's id.
Type
number | string

getPosition() → {Grape2D.Vector}

Gets the object position. Be careful, because it returns the vector used by the object, and not a copy. Use it wisely.
Inherited From:
Source:
Returns:
The position of the object.
Type
Grape2D.Vector

getTexture() → {Grape2D.Texture}

Gets the texture of the object.
Inherited From:
Source:
Returns:
The texture of the object.
Type
Grape2D.Texture

getTextureOffset() → {Grape2D.Vector}

Gets the texture offset
Inherited From:
Source:
Returns:
The texture offset.
Type
Grape2D.Vector

getTexturePosition() → {Grape2D.Vector}

Gets the texture position.
Inherited From:
Source:
Returns:
The position of the texture
Type
Grape2D.Vector

isVisible() → {boolean}

Checks if the object should be rendered.
Inherited From:
Source:
Returns:
True if it can be rendered.
Type
boolean

process()

Source:

render()

Source:

renderInterpolate(renderer, camera, lerpPosition)

Renders an object in an interpolating position.
Parameters:
Name Type Description
renderer Grape2D.Renderer Renderer.
camera Grape2D.Camera Camera.
lerpPosition Grape2D.Vector Interpolating position.
Source:

setBoundingBox(boundingBox)

Sets the bounding box of the object. Also, the position of the new bounding box, will be transformed in the default offset of the bounding box.
Parameters:
Name Type Description
boundingBox Grape2D.Shape The bounding box.
Inherited From:
Source:

setBoundingBoxOffset(offset)

Sets the bounding box offset.
Parameters:
Name Type Description
offset Grape2D.Vector The offset of the bounding box, from the object's position.
Inherited From:
Source:

setCastShadow(castShadow)

Sets if an object can cast shadows.
Parameters:
Name Type Description
castShadow boolean True to cast shadows, false otherwise.
Inherited From:
Source:

setId(id)

Sets the object's id.
Parameters:
Name Type Description
id number | string Object's id.
Source:

setPosition(position)

Sets the object position.
Parameters:
Name Type Description
position Grape2D.Vector The position of the object.
Inherited From:
Source:

setReceiveLight(receiveLight)

Sets if the object can receive light.
Parameters:
Name Type Description
receiveLight boolean True if it receives light.
Inherited From:
Source:

setTexture(texture)

Sets the texture of the object.
Parameters:
Name Type Description
texture Grape2D.Texture The texture.
Inherited From:
Source:

setTextureOffset(offset)

Sets the texture offset.
Parameters:
Name Type Description
offset Grape2D.Vector The offset of the texture, from the object's position.
Inherited From:
Source:

setVisible(visible)

Sets if an object should be rendered.
Parameters:
Name Type Description
visible boolean True, so that it renders, false otherwise.
Inherited From:
Source:

update(dt, scene)

Updates the object. This method should be refined in further subclasses if needed be.
Parameters:
Name Type Description
dt number Time interval.
scene Grape2D.Scene Scene where this object is.
Inherited From:
Source: