Skip to content

Commit

Permalink
Sync object layer too
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementPasteau committed Jun 18, 2024
1 parent 0020f72 commit 727a755
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 8 additions & 0 deletions GDJS/Runtime/runtimeobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ namespace gdjs {
zo: this.zOrder,
a: this.angle,
hid: this.hidden,
lay: this.layer,
if: this._instantForces.map((force) => force.getNetworkSyncData()),
pfx: this._permanentForceX,
pfy: this._permanentForceY,
Expand Down Expand Up @@ -524,6 +525,13 @@ namespace gdjs {
this.hide(networkSyncData.hid);
}

if (
networkSyncData.lay !== undefined &&
this.layer !== networkSyncData.lay
) {
this.setLayer(networkSyncData.lay);
}

if (networkSyncData.if) {
// Force clear all forces and reapply them, using the garbage collector to recycle forces.
// Is that efficient?
Expand Down
14 changes: 8 additions & 6 deletions GDJS/Runtime/types/project-data.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@ declare type GetNetworkSyncDataOptions = { playerNumber?: number };

/** Object containing basic properties for all objects synchronizing over the network. */
declare type BasicObjectNetworkSyncData = {
/** The position of the object on the X axis. */
/** The position of the instance on the X axis. */
x: number;
/** The position of the object on the Y axis. */
/** The position of the instance on the Y axis. */
y: number;
/** The position of the object on the Z axis. Defined only for 3D games */
/** The position of the instance on the Z axis. Defined only for 3D games */
z?: number;
/** Z order of the object */
/** Z order of the instance */
zo: number;
/** The angle of the object. */
/** The angle of the instance. */
a: number;
/** If the object is hidden */
/** If the instance is hidden */
hid: boolean;
/** The layer where the instance lives */
lay: string;
/** All the instant forces */
if: Array<ForceNetworkSyncData>;
/** Permanent force on X */
Expand Down

0 comments on commit 727a755

Please sign in to comment.