Skip to content

Commit ae80962

Browse files
author
Julien
committed
feat(sdk): added setSkew to Graphics module
1 parent 6643548 commit ae80962

File tree

4 files changed

+86
-1
lines changed

4 files changed

+86
-1
lines changed

engine/modules/entities/src/main/java/com/codingame/gameengine/module/entities/Entity.java

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public abstract class Entity<T extends Entity<?>> {
1717

1818
private int x, y, zIndex;
1919
private double scaleX = 1, scaleY = 1;
20+
private double skewX = 0, skewY = 0;
2021
private boolean visible = false;
2122
private double rotation, alpha = 1;
2223
ContainerBasedEntity<?> parent;
@@ -184,6 +185,58 @@ public T setScaleY(double scaleY, Curve curve) {
184185
return self();
185186
}
186187

188+
/**
189+
* Sets the horizontal skew of this <code>Entity</code> in radians.
190+
*
191+
* @param skewX
192+
* the horizontal skew for this <code>Entity</code>.
193+
* @return this <code>Entity</code>.
194+
*/
195+
public T setSkewX(double skewX) {
196+
return setSkewX(skewX, null);
197+
}
198+
199+
/**
200+
* Sets the horizontal skew of this <code>Entity</code> in radians.
201+
*
202+
* @param skewX
203+
* the horizontal skew for this <code>Entity</code>.
204+
* @param curve
205+
* the transition to animate between values of this property.
206+
* @return this <code>Entity</code>.
207+
*/
208+
public T setSkewX(double skewX, Curve curve) {
209+
this.skewX = skewX;
210+
set("skewX", skewX, curve);
211+
return self();
212+
}
213+
214+
/**
215+
* Sets the vertical skew of this <code>Entity</code> in radians.
216+
*
217+
* @param skewY
218+
* the vertical skew for this <code>Entity</code>.
219+
* @return this <code>Entity</code>.
220+
*/
221+
public T setSkewY(double skewY) {
222+
return setSkewY(skewY, null);
223+
}
224+
225+
/**
226+
* Sets the vertical skew of this <code>Entity</code> in radians.
227+
*
228+
* @param skewY
229+
* the vertical skew for this <code>Entity</code>.
230+
* @param curve
231+
* the transition to animate between values of this property.
232+
* @return this <code>Entity</code>.
233+
*/
234+
public T setSkewY(double skewY, Curve curve) {
235+
this.skewY = skewY;
236+
set("skewY", skewY, curve);
237+
return self();
238+
}
239+
187240
/**
188241
* <p>
189242
* Sets the alpha of this <code>Entity</code> as a percentage.
@@ -342,6 +395,30 @@ public double getScaleY() {
342395
return scaleY;
343396
}
344397

398+
/**
399+
* Returns the horizontal skew of this <code>Entity</code> in radians.
400+
* <p>
401+
* Default is 0.
402+
* </p>
403+
*
404+
* @return the horizontal skew of this <code>Entity</code>.
405+
*/
406+
public double getSkewX() {
407+
return skewX;
408+
}
409+
410+
/**
411+
* Returns the vertical skew of this <code>Entity</code> in radians.
412+
* <p>
413+
* Default is 0.
414+
* </p>
415+
*
416+
* @return the vertical skew of this <code>Entity</code>.
417+
*/
418+
public double getSkewY() {
419+
return skewY;
420+
}
421+
345422
/**
346423
* Returns the alpha of this <code>Entity</code> as a percentage.
347424
* <p>

engine/modules/entities/src/main/java/com/codingame/gameengine/module/entities/Serializer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class Serializer {
6666
keys.put("baseWidth", "bw");
6767
keys.put("baseHeight", "bh");
6868
keys.put("points", "ps");
69+
keys.put("skewX", "kx");
70+
keys.put("skewY", "ky");
6971

7072
commands = new HashMap<>();
7173
commands.put("CREATE", "C");

engine/modules/entities/src/main/resources/view/entity-module/Command.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const PROPERTY_KEY_MAP = {
3131
sy: 'scaleY',
3232
ax: 'anchorX',
3333
ay: 'anchorY',
34+
kx: 'skewX',
35+
ky: 'skewY',
3436
v: 'visible',
3537
z: 'zIndex',
3638
b: 'blendMode',

playground/misc/misc-3-release-notes.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
The CodinGame SDK is regularly updated and improved. This document lets you know what changed in the latest releases.
44

5-
## Next versions
5+
## Next Release
6+
7+
### 🎁 New features
8+
9+
- Added methods to change an entity's `skew` in the `GraphicEntityModule`
610

711
## 3.4.10
812

0 commit comments

Comments
 (0)