Skip to content

Commit

Permalink
entity flip x/y
Browse files Browse the repository at this point in the history
  • Loading branch information
evolutionleo committed Nov 29, 2024
1 parent 2abfc7d commit 5ae62b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Client/objects/oEntityManager/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ for(i = 0; i < l; i++) {
inst.x = entity.x
inst.y = entity.y

if (entity[$ "fx"]) {
inst.image_xscale *= -1
}
if (entity[$ "fy"]) {
inst.image_yscale *= -1
}

inst.state = state

// set the speed
Expand Down
12 changes: 11 additions & 1 deletion TypescriptServer/src/concepts/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export type SerializedEntity = {
a: number,
spd?: Point,
st: number, // state
fx?: boolean, // flip
fy?: boolean,

p?: { // custom variables
[name: string]: any
Expand Down Expand Up @@ -344,7 +346,7 @@ class Entity extends EventEmitter {
}

public serialize():SerializedEntity {
return {
let struct:SerializedEntity = {
id: this.id,
t: this.type,
obj: this.object_name,
Expand All @@ -357,6 +359,14 @@ class Entity extends EventEmitter {
p: this.props, // uses a getter for props
st: this.state
}

if (this.flip.x)
struct.fx = true;
if (this.flip.y)
struct.fy = true;


return struct;
}

public bundle() {
Expand Down

0 comments on commit 5ae62b3

Please sign in to comment.