rngine 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -0,0 +1,56 @@
1
+ package com.margelo.nitro.rngine
2
+
3
+ import android.util.Log
4
+ import androidx.annotation.Keep
5
+ import com.margelo.nitro.NitroModules
6
+ import java.io.IOException
7
+ import java.net.URL
8
+
9
+ @Keep
10
+ object ImageLoaderHelper {
11
+ @JvmStatic
12
+ fun loadFromUrl(uri: String): ByteArray {
13
+ Log.d("ImageLoaderHelper", "loadFromUrl: fetching $uri")
14
+ return try {
15
+ val bytes = URL(uri).openStream().use { it.readBytes() }
16
+ Log.d("ImageLoaderHelper", "loadFromUrl: success, ${bytes.size} bytes for $uri")
17
+ bytes
18
+ } catch (e: IOException) {
19
+ Log.e("ImageLoaderHelper", "loadFromUrl: network/IO failure for $uri", e)
20
+ throw e
21
+ } catch (e: Exception) {
22
+ Log.e("ImageLoaderHelper", "loadFromUrl: unexpected failure for $uri", e)
23
+ throw e
24
+ }
25
+ }
26
+
27
+ @JvmStatic
28
+ fun loadFromResource(uri: String): ByteArray {
29
+ Log.d("ImageLoaderHelper", "loadFromResource: resolving resource for '$uri'")
30
+ val context = NitroModules.applicationContext
31
+ if (context == null) {
32
+ Log.e(
33
+ "ImageLoaderHelper",
34
+ "loadFromResource: applicationContext is null, NitroModules not initialized?"
35
+ )
36
+ throw IllegalStateException("No Context available!")
37
+ }
38
+ var resId = context.resources.getIdentifier(uri, "raw", context.packageName)
39
+ if (resId == 0) {
40
+ resId = context.resources.getIdentifier(uri, "drawable", context.packageName)
41
+ }
42
+ if (resId == 0) {
43
+ Log.e("ImageLoaderHelper", "loadFromResource: no resource found for '$uri'")
44
+ throw IllegalStateException("Could not resolve raw resource for asset: $uri")
45
+ }
46
+ Log.d("ImageLoaderHelper", "loadFromResource: resolved '$uri' -> resId=$resId")
47
+ return try {
48
+ val bytes = context.resources.openRawResource(resId).use { it.readBytes() }
49
+ Log.d("ImageLoaderHelper", "loadFromResource: success, ${bytes.size} bytes for '$uri'")
50
+ bytes
51
+ } catch (e: Exception) {
52
+ Log.e("ImageLoaderHelper", "loadFromResource: failed reading resId=$resId for '$uri'", e)
53
+ throw e
54
+ }
55
+ }
56
+ }
@@ -81,9 +81,9 @@ const loadAsset = async asset => {
81
81
  if (!assetUri) {
82
82
  throw new Error(`loadAssets: could not resolve asset URI for ${asset}`);
83
83
  }
84
- const isSvgLoaded = await gameMethods.loadSvg(asset, assetUri);
85
- if (!isSvgLoaded) {
86
- throw new Error('loadAssets: Failed to load svg asset');
84
+ const isLoaded = await gameMethods.loadImage(asset, assetUri);
85
+ if (!isLoaded) {
86
+ throw new Error('loadAssets: Failed to load image asset');
87
87
  }
88
88
  return asset;
89
89
  }
@@ -1 +1 @@
1
- {"version":3,"names":["gameMethods","Image","configure","world","screen","entities","systems","paused","nativeSystems","system","push","collisions","onTick","e","c","start","Date","now","finish","setWorld","setScreen","setEntities","setSystems","pause","resume","spawn","entityArray","Array","isArray","despawn","id","update","updates","entityUpdateArray","assetCache","WeakMap","nextId","loadAsset","asset","Error","has","get","assetId","set","isLottieLoaded","loadLottie","JSON","stringify","isAssetLoaded","assetUri","resolveAssetSource","uri","isSvgLoaded","loadSvg","loadAssets","assets","keys","Object","result","key"],"sourceRoot":"../../src","sources":["GameMethods.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,wBAAqB;AAGjD,SAASC,KAAK,QAAQ,cAAc;;AAEpC;AACA,OAAO,MAAMC,SAAS,GAAGA,CAAC;EACxBC,KAAK;EACLC,MAAM;EACNC,QAAQ,GAAG,EAAE;EACbC,OAAO,GAAG,EAAE;EACZC,MAAM,GAAG;AACH,CAAC,KAAK;EACZ,IAAIC,aAAuB,GAAG,EAAE;EAEhC,KAAK,MAAMC,MAAM,IAAIH,OAAO,EAAE;IAC5BE,aAAa,CAACE,IAAI,CAAC;MACjBL,QAAQ,EAAEI,MAAM,CAACJ,QAAQ;MAC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zD;MACA,OAAOD,KAAK;EAChB;EAEA,MAAM,IAAIC,KAAK,CAAC,uCAAuC,OAAOD,KAAK,GAAG,CAAC;AACzE,CAAC;AAED,OAAO,MAAMgB,UAAU,GAAG,MACxBC,MAAS,IAC+B;EACxC,MAAMC,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACD,MAAM,CAAgB;EAC/C,MAAMG,MAAM,GAAG,CAAC,CAA+B;EAE/C,KAAK,MAAMC,GAAG,IAAIH,IAAI,EAAE;IACtBE,MAAM,CAACC,GAAG,CAAC,GAAG,MAAMtB,SAAS,CAACkB,MAAM,CAACI,GAAG,CAAC,CAAC;EAC5C;EAEA,OAAOD,MAAM;AACf,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["gameMethods","Image","configure","world","screen","entities","systems","paused","nativeSystems","system","push","collisions","onTick","e","c","start","Date","now","finish","setWorld","setScreen","setEntities","setSystems","pause","resume","spawn","entityArray","Array","isArray","despawn","id","update","updates","entityUpdateArray","assetCache","WeakMap","nextId","loadAsset","asset","Error","has","get","assetId","set","isLottieLoaded","loadLottie","JSON","stringify","isAssetLoaded","assetUri","resolveAssetSource","uri","isLoaded","loadImage","loadAssets","assets","keys","Object","result","key"],"sourceRoot":"../../src","sources":["GameMethods.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,wBAAqB;AAGjD,SAASC,KAAK,QAAQ,cAAc;;AAEpC;AACA,OAAO,MAAMC,SAAS,GAAGA,CAAC;EACxBC,KAAK;EACLC,MAAM;EACNC,QAAQ,GAAG,EAAE;EACbC,OAAO,GAAG,EAAE;EACZC,MAAM,GAAG;AACH,CAAC,KAAK;EACZ,IAAIC,aAAuB,GAAG,EAAE;EAEhC,KAAK,MAAMC,MAAM,IAAIH,OAAO,EAAE;IAC5BE,aAAa,CAACE,IAAI,CAAC;MACjBL,QAAQ,EAAEI,MAAM,CAACJ,QAAQ;MACzBM,UAAU,EAAEF,MAAM,CAACE,UAAU;MAC7BC,MAAM,EAAEA,CAACC,CAA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C,OAAOD,KAAK,GAAG,CAAC;AACzE,CAAC;AAED,OAAO,MAAMgB,UAAU,GAAG,MACxBC,MAAS,IAC+B;EACxC,MAAMC,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACD,MAAM,CAAgB;EAC/C,MAAMG,MAAM,GAAG,CAAC,CAA+B;EAE/C,KAAK,MAAMC,GAAG,IAAIH,IAAI,EAAE;IACtBE,MAAM,CAACC,GAAG,CAAC,GAAG,MAAMtB,SAAS,CAACkB,MAAM,CAACI,GAAG,CAAC,CAAC;EAC5C;EAEA,OAAOD,MAAM;AACf,CAAC","ignoreList":[]}
@@ -15,7 +15,7 @@ interface GameMethods extends HybridObject<{
15
15
  update(updates: EntityUpdate[]): void;
16
16
  isAssetLoaded(id: number): boolean;
17
17
  loadLottie(id: number, jsonStr: string): Promise<boolean>;
18
- loadSvg(id: number, svgUri: string): Promise<boolean>;
18
+ loadImage(id: number, imageUri: string): Promise<boolean>;
19
19
  }
20
20
  export declare const gameMethods: GameMethods;
21
21
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"GameMethods.nitro.d.ts","sourceRoot":"","sources":["../../../src/GameMethods.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,MAAM,EACN,MAAM,EACN,KAAK,EACN,MAAM,eAAe,CAAC;AAGvB,UAAU,WAAY,SAAQ,YAAY,CAAC;IACzC,GAAG,EAAE,KAAK,CAAC;IACX,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;IACA,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACtC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACpC,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,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAEtC,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1D,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3D;AAED,eAAO,MAAM,WAAW,aACqC,CAAC"}
@@ -25,8 +25,14 @@ interface Renderable {
25
25
  color?: string;
26
26
  /** Asset to render, use `require` with the file path to get the id. */
27
27
  asset?: number;
28
+ /** Whether to flip the rendered asset horizontally. */
29
+ flipH?: boolean;
30
+ /** Whether to flip the rendered asset vertically. */
31
+ flipV?: boolean;
28
32
  /** Animation progress between 0 and 1, automatically advanced each tick for Lottie assets. */
29
33
  progress?: number;
34
+ /** Playback speed multiplier for animated assets (1 = normal speed). */
35
+ speed?: number;
30
36
  }
31
37
  interface Kinematic {
32
38
  /** Horizontal velocity in game units per second. */
@@ -1 +1 @@
1
- {"version":3,"file":"nativeTypes.d.ts","sourceRoot":"","sources":["../../../src/nativeTypes.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,UAAU,IAAI;IACZ,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,MAAM;IACd,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,MAAM;IACd,2BAA2B;IAC3B,KAAK,EAAE,IAAI,GAAG,MAAM,CAAC;IACrB,6GAA6G;IAC7G,QAAQ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AAE,aAAa,EAAE,CAAC;IAC7B,mEAAmE;IACnE,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,MAAM,CAAC;CACjE"}
@@ -53,7 +53,10 @@ namespace margelo::nitro::rngine {
53
53
  std::optional<bool> isSensor SWIFT_PRIVATE;
54
54
  std::optional<std::string> color SWIFT_PRIVATE;
55
55
  std::optional<double> asset SWIFT_PRIVATE;
56
+ std::optional<bool> flipH SWIFT_PRIVATE;
57
+ std::optional<bool> flipV SWIFT_PRIVATE;
56
58
  std::optional<double> progress SWIFT_PRIVATE;
59
+ std::optional<double> speed SWIFT_PRIVATE;
57
60
  std::optional<double> vx SWIFT_PRIVATE;
58
61
  std::optional<double> vy SWIFT_PRIVATE;
59
62
  std::optional<double> ax SWIFT_PRIVATE;
@@ -62,7 +65,7 @@ namespace margelo::nitro::rngine {
62
65
 
63
66
  public:
64
67
  Entity() = default;
65
- explicit Entity(std::string id, double px, double py, std::variant<Rect, Circle> shape, std::optional<bool> isSensor, std::optional<std::string> color, std::optional<double> asset, std::optional<double> progress, std::optional<double> vx, std::optional<double> vy, std::optional<double> ax, std::optional<double> ay, std::optional<double> mass): id(id), px(px), py(py), shape(shape), isSensor(isSensor), color(color), asset(asset), progress(progress), vx(vx), vy(vy), ax(ax), ay(ay), mass(mass) {}
68
+ explicit Entity(std::string id, double px, double py, std::variant<Rect, Circle> shape, std::optional<bool> isSensor, std::optional<std::string> color, std::optional<double> asset, std::optional<bool> flipH, std::optional<bool> flipV, std::optional<double> progress, std::optional<double> speed, std::optional<double> vx, std::optional<double> vy, std::optional<double> ax, std::optional<double> ay, std::optional<double> mass): id(id), px(px), py(py), shape(shape), isSensor(isSensor), color(color), asset(asset), flipH(flipH), flipV(flipV), progress(progress), speed(speed), vx(vx), vy(vy), ax(ax), ay(ay), mass(mass) {}
66
69
 
67
70
  public:
68
71
  friend bool operator==(const Entity& lhs, const Entity& rhs) = default;
@@ -85,7 +88,10 @@ namespace margelo::nitro {
85
88
  JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSensor"))),
86
89
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "color"))),
87
90
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "asset"))),
91
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flipH"))),
92
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flipV"))),
88
93
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progress"))),
94
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed"))),
89
95
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vx"))),
90
96
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vy"))),
91
97
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ax"))),
@@ -102,7 +108,10 @@ namespace margelo::nitro {
102
108
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "isSensor"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isSensor));
103
109
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "color"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.color));
104
110
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "asset"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.asset));
111
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "flipH"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.flipH));
112
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "flipV"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.flipV));
105
113
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "progress"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.progress));
114
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "speed"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.speed));
106
115
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "vx"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.vx));
107
116
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "vy"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.vy));
108
117
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "ax"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.ax));
@@ -125,7 +134,10 @@ namespace margelo::nitro {
125
134
  if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSensor")))) return false;
126
135
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "color")))) return false;
127
136
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "asset")))) return false;
137
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flipH")))) return false;
138
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flipV")))) return false;
128
139
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progress")))) return false;
140
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed")))) return false;
129
141
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vx")))) return false;
130
142
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vy")))) return false;
131
143
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ax")))) return false;
@@ -53,7 +53,10 @@ namespace margelo::nitro::rngine {
53
53
  std::optional<bool> isSensor SWIFT_PRIVATE;
54
54
  std::optional<std::string> color SWIFT_PRIVATE;
55
55
  std::optional<double> asset SWIFT_PRIVATE;
56
+ std::optional<bool> flipH SWIFT_PRIVATE;
57
+ std::optional<bool> flipV SWIFT_PRIVATE;
56
58
  std::optional<double> progress SWIFT_PRIVATE;
59
+ std::optional<double> speed SWIFT_PRIVATE;
57
60
  std::optional<double> vx SWIFT_PRIVATE;
58
61
  std::optional<double> vy SWIFT_PRIVATE;
59
62
  std::optional<double> ax SWIFT_PRIVATE;
@@ -62,7 +65,7 @@ namespace margelo::nitro::rngine {
62
65
 
63
66
  public:
64
67
  EntityUpdate() = default;
65
- explicit EntityUpdate(std::string id, std::optional<double> px, std::optional<double> py, std::optional<std::variant<Rect, Circle>> shape, std::optional<bool> isSensor, std::optional<std::string> color, std::optional<double> asset, std::optional<double> progress, std::optional<double> vx, std::optional<double> vy, std::optional<double> ax, std::optional<double> ay, std::optional<double> mass): id(id), px(px), py(py), shape(shape), isSensor(isSensor), color(color), asset(asset), progress(progress), vx(vx), vy(vy), ax(ax), ay(ay), mass(mass) {}
68
+ explicit EntityUpdate(std::string id, std::optional<double> px, std::optional<double> py, std::optional<std::variant<Rect, Circle>> shape, std::optional<bool> isSensor, std::optional<std::string> color, std::optional<double> asset, std::optional<bool> flipH, std::optional<bool> flipV, std::optional<double> progress, std::optional<double> speed, std::optional<double> vx, std::optional<double> vy, std::optional<double> ax, std::optional<double> ay, std::optional<double> mass): id(id), px(px), py(py), shape(shape), isSensor(isSensor), color(color), asset(asset), flipH(flipH), flipV(flipV), progress(progress), speed(speed), vx(vx), vy(vy), ax(ax), ay(ay), mass(mass) {}
66
69
 
67
70
  public:
68
71
  friend bool operator==(const EntityUpdate& lhs, const EntityUpdate& rhs) = default;
@@ -85,7 +88,10 @@ namespace margelo::nitro {
85
88
  JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSensor"))),
86
89
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "color"))),
87
90
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "asset"))),
91
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flipH"))),
92
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flipV"))),
88
93
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progress"))),
94
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed"))),
89
95
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vx"))),
90
96
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vy"))),
91
97
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ax"))),
@@ -102,7 +108,10 @@ namespace margelo::nitro {
102
108
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "isSensor"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isSensor));
103
109
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "color"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.color));
104
110
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "asset"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.asset));
111
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "flipH"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.flipH));
112
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "flipV"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.flipV));
105
113
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "progress"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.progress));
114
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "speed"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.speed));
106
115
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "vx"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.vx));
107
116
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "vy"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.vy));
108
117
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "ax"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.ax));
@@ -125,7 +134,10 @@ namespace margelo::nitro {
125
134
  if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSensor")))) return false;
126
135
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "color")))) return false;
127
136
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "asset")))) return false;
137
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flipH")))) return false;
138
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flipV")))) return false;
128
139
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progress")))) return false;
140
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed")))) return false;
129
141
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vx")))) return false;
130
142
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vy")))) return false;
131
143
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ax")))) return false;
@@ -25,7 +25,7 @@ namespace margelo::nitro::rngine {
25
25
  prototype.registerHybridMethod("update", &HybridGameMethodsSpec::update);
26
26
  prototype.registerHybridMethod("isAssetLoaded", &HybridGameMethodsSpec::isAssetLoaded);
27
27
  prototype.registerHybridMethod("loadLottie", &HybridGameMethodsSpec::loadLottie);
28
- prototype.registerHybridMethod("loadSvg", &HybridGameMethodsSpec::loadSvg);
28
+ prototype.registerHybridMethod("loadImage", &HybridGameMethodsSpec::loadImage);
29
29
  });
30
30
  }
31
31
 
@@ -75,7 +75,7 @@ namespace margelo::nitro::rngine {
75
75
  virtual void update(const std::vector<EntityUpdate>& updates) = 0;
76
76
  virtual bool isAssetLoaded(double id) = 0;
77
77
  virtual std::shared_ptr<Promise<bool>> loadLottie(double id, const std::string& jsonStr) = 0;
78
- virtual std::shared_ptr<Promise<bool>> loadSvg(double id, const std::string& svgUri) = 0;
78
+ virtual std::shared_ptr<Promise<bool>> loadImage(double id, const std::string& imageUri) = 0;
79
79
 
80
80
  protected:
81
81
  // Hybrid Setup
@@ -44,11 +44,14 @@ namespace margelo::nitro::rngine {
44
44
  double height SWIFT_PRIVATE;
45
45
  std::optional<std::string> color SWIFT_PRIVATE;
46
46
  std::optional<double> asset SWIFT_PRIVATE;
47
+ std::optional<bool> flipH SWIFT_PRIVATE;
48
+ std::optional<bool> flipV SWIFT_PRIVATE;
47
49
  std::optional<double> progress SWIFT_PRIVATE;
50
+ std::optional<double> speed SWIFT_PRIVATE;
48
51
 
49
52
  public:
50
53
  Screen() = default;
51
- explicit Screen(double width, double height, std::optional<std::string> color, std::optional<double> asset, std::optional<double> progress): width(width), height(height), color(color), asset(asset), progress(progress) {}
54
+ explicit Screen(double width, double height, std::optional<std::string> color, std::optional<double> asset, std::optional<bool> flipH, std::optional<bool> flipV, std::optional<double> progress, std::optional<double> speed): width(width), height(height), color(color), asset(asset), flipH(flipH), flipV(flipV), progress(progress), speed(speed) {}
52
55
 
53
56
  public:
54
57
  friend bool operator==(const Screen& lhs, const Screen& rhs) = default;
@@ -68,7 +71,10 @@ namespace margelo::nitro {
68
71
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height"))),
69
72
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "color"))),
70
73
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "asset"))),
71
- JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progress")))
74
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flipH"))),
75
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flipV"))),
76
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progress"))),
77
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed")))
72
78
  );
73
79
  }
74
80
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rngine::Screen& arg) {
@@ -77,7 +83,10 @@ namespace margelo::nitro {
77
83
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter<double>::toJSI(runtime, arg.height));
78
84
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "color"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.color));
79
85
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "asset"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.asset));
86
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "flipH"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.flipH));
87
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "flipV"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.flipV));
80
88
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "progress"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.progress));
89
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "speed"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.speed));
81
90
  return obj;
82
91
  }
83
92
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -92,7 +101,10 @@ namespace margelo::nitro {
92
101
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) return false;
93
102
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "color")))) return false;
94
103
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "asset")))) return false;
104
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flipH")))) return false;
105
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flipV")))) return false;
95
106
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progress")))) return false;
107
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed")))) return false;
96
108
  return true;
97
109
  }
98
110
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rngine",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "React Native 2D game engine powered by Nitro Modules",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -183,9 +183,12 @@ void GameLoop::updateScreen(double deltaTime) {
183
183
  auto &lottieCache = GameRenderer::getInstance().getLottieCacheInternal();
184
184
  auto it = lottieCache.find(_screen.asset.value());
185
185
  if (it != lottieCache.end() && it->second) {
186
- _screen.progress = fmod(_screen.progress.value_or(0.0) +
187
- deltaTime / it->second->duration(),
188
- 1.0);
186
+ if (_screen.speed.has_value() && _screen.speed.value() > 0) {
187
+ _screen.progress = fmod(_screen.progress.value_or(0.0) +
188
+ (deltaTime * _screen.speed.value()) /
189
+ it->second->duration(),
190
+ 1.0);
191
+ }
189
192
  }
190
193
  } else if (_screen.progress.has_value()) {
191
194
  _screen.progress.reset();
@@ -225,9 +228,12 @@ void GameLoop::updateEntities(double deltaTime) {
225
228
  auto &lottieCache = GameRenderer::getInstance().getLottieCacheInternal();
226
229
  auto it = lottieCache.find(entity.asset.value());
227
230
  if (it != lottieCache.end() && it->second) {
228
- entity.progress = fmod(entity.progress.value_or(0.0) +
229
- deltaTime / it->second->duration(),
230
- 1.0);
231
+ if (entity.speed.has_value() && entity.speed.value() > 0) {
232
+ entity.progress = fmod(entity.progress.value_or(0.0) +
233
+ (deltaTime * entity.speed.value()) /
234
+ it->second->duration(),
235
+ 1.0);
236
+ }
231
237
  }
232
238
  } else if (entity.progress.has_value()) {
233
239
  entity.progress.reset();
@@ -2,6 +2,7 @@
2
2
  #include "EntityUpdate.hpp"
3
3
  #include "GameLoop.hpp"
4
4
  #include "GameRenderer.hpp"
5
+ #include "include/core/SkImage.h"
5
6
  #include "include/core/SkStream.h"
6
7
  #include <android/log.h>
7
8
  #include <fbjni/fbjni.h>
@@ -137,9 +138,18 @@ void GameMethods::update(const std::vector<EntityUpdate> &updates) {
137
138
  if (update.progress.has_value()) {
138
139
  entity->progress = update.progress.value();
139
140
  }
141
+ if (update.speed.has_value()) {
142
+ entity->speed = update.speed.value();
143
+ }
140
144
  if (update.color.has_value()) {
141
145
  entity->color = update.color.value();
142
146
  }
147
+ if (update.flipH.has_value()) {
148
+ entity->flipH = update.flipH.value();
149
+ }
150
+ if (update.flipV.has_value()) {
151
+ entity->flipV = update.flipV.value();
152
+ }
143
153
  if (update.vx.has_value()) {
144
154
  entity->vx = update.vx.value();
145
155
  }
@@ -167,9 +177,9 @@ bool GameMethods::isAssetLoaded(double id) {
167
177
  auto &gameRenderer = GameRenderer::getInstance();
168
178
 
169
179
  if (id > 0) {
170
- auto &svgCache = gameRenderer.getSvgCacheInternal();
171
- auto it = svgCache.find(id);
172
- return it != svgCache.end();
180
+ auto &imageCache = gameRenderer.getImageCacheInternal();
181
+ auto it = imageCache.find(id);
182
+ return it != imageCache.end();
173
183
  }
174
184
 
175
185
  if (id < 0) {
@@ -184,8 +194,12 @@ bool GameMethods::isAssetLoaded(double id) {
184
194
  std::shared_ptr<Promise<bool>>
185
195
  GameMethods::loadLottie(double id, const std::string &jsonStr) {
186
196
  return Promise<bool>::async([=]() -> bool {
187
- auto stream = SkMemoryStream::MakeDirect(jsonStr.data(), jsonStr.size());
188
- auto animation = skottie::Animation::Make(stream.get());
197
+ auto resourceProvider = skresources::DataURIResourceProviderProxy::Make(
198
+ nullptr, skresources::ImageDecodeStrategy::kLazyDecode);
199
+
200
+ auto animation = skottie::Animation::Builder()
201
+ .setResourceProvider(resourceProvider)
202
+ .make(jsonStr.data(), jsonStr.size());
189
203
 
190
204
  if (!animation) {
191
205
  return false;
@@ -200,53 +214,86 @@ GameMethods::loadLottie(double id, const std::string &jsonStr) {
200
214
  });
201
215
  };
202
216
 
203
- std::shared_ptr<Promise<bool>> GameMethods::loadSvg(double id,
204
- const std::string &svgUri) {
217
+ std::shared_ptr<Promise<bool>>
218
+ GameMethods::loadImage(double id, const std::string &imageUri) {
205
219
  return Promise<bool>::async([=]() -> bool {
206
- std::string svgStr;
220
+ __android_log_print(ANDROID_LOG_DEBUG, "GameMethods",
221
+ "loadImage: start id=%.0f uri=%s", id,
222
+ imageUri.c_str());
223
+ std::string imageStr;
207
224
 
208
225
  using namespace facebook::jni;
209
226
 
210
- ThreadScope::WithClassLoader([&] {
211
- static const auto helperClass =
212
- findClassStatic("com/margelo/nitro/rngine/SvgLoaderHelper");
213
-
214
- local_ref<JArrayByte> byteArray;
215
-
216
- if (svgUri.rfind("http://", 0) == 0 || svgUri.rfind("https://", 0) == 0) {
217
- static const auto method =
218
- helperClass->getStaticMethod<JArrayByte(local_ref<JString>)>(
219
- "loadFromUrl");
220
- byteArray = method(helperClass, make_jstring(svgUri));
221
- } else {
222
- static const auto method =
223
- helperClass->getStaticMethod<JArrayByte(local_ref<JString>)>(
224
- "loadFromResource");
225
- byteArray = method(helperClass, make_jstring(svgUri));
226
- }
227
+ try {
228
+ ThreadScope::WithClassLoader([&] {
229
+ static const auto helperClass =
230
+ findClassStatic("com/margelo/nitro/rngine/ImageLoaderHelper");
231
+
232
+ local_ref<JArrayByte> byteArray;
233
+
234
+ if (imageUri.rfind("http://", 0) == 0 ||
235
+ imageUri.rfind("https://", 0) == 0) {
236
+ static const auto method =
237
+ helperClass->getStaticMethod<JArrayByte(local_ref<JString>)>(
238
+ "loadFromUrl");
239
+ byteArray = method(helperClass, make_jstring(imageUri));
240
+ } else {
241
+ static const auto method =
242
+ helperClass->getStaticMethod<JArrayByte(local_ref<JString>)>(
243
+ "loadFromResource");
244
+ byteArray = method(helperClass, make_jstring(imageUri));
245
+ }
246
+
247
+ if (!byteArray) {
248
+ throw std::runtime_error("Failed to load image bytes for: " +
249
+ imageUri);
250
+ }
251
+
252
+ size_t len = byteArray->size();
253
+ imageStr.resize(len);
254
+ byteArray->getRegion(0, len,
255
+ reinterpret_cast<int8_t *>(imageStr.data()));
256
+ });
257
+ } catch (const std::exception &e) {
258
+ __android_log_print(ANDROID_LOG_ERROR, "GameMethods",
259
+ "loadImage: JNI fetch failed id=%.0f: %s", id,
260
+ e.what());
261
+ return false;
262
+ }
227
263
 
228
- if (!byteArray) {
229
- throw std::runtime_error("Failed to load SVG bytes for: " + svgUri);
230
- }
264
+ __android_log_print(ANDROID_LOG_DEBUG, "GameMethods",
265
+ "loadImage: fetched %zu bytes id=%.0f", imageStr.size(),
266
+ id);
231
267
 
232
- size_t len = byteArray->size();
233
- svgStr.resize(len);
234
- byteArray->getRegion(0, len, reinterpret_cast<int8_t *>(svgStr.data()));
235
- });
268
+ auto &gameRenderer = GameRenderer::getInstance();
269
+ auto &imageCache = gameRenderer.getImageCacheInternal();
236
270
 
237
- auto stream = SkMemoryStream::MakeDirect(svgStr.data(), svgStr.size());
271
+ auto stream = SkMemoryStream::MakeDirect(imageStr.data(), imageStr.size());
238
272
  auto svgDom = SkSVGDOM::MakeFromStream(*stream);
239
273
 
240
- if (!svgDom) {
241
- return false;
274
+ if (svgDom) {
275
+ __android_log_print(ANDROID_LOG_DEBUG, "GameMethods",
276
+ "loadImage: parsed as SVG id=%.0f", id);
277
+ imageCache[id] = std::move(svgDom);
278
+ return true;
242
279
  }
243
280
 
244
- auto &gameRenderer = GameRenderer::getInstance();
245
- auto &svgCache = gameRenderer.getSvgCacheInternal();
281
+ auto data = SkData::MakeWithCopy(imageStr.data(), imageStr.size());
282
+ auto raster = SkImages::DeferredFromEncodedData(std::move(data));
246
283
 
247
- svgCache[id] = std::move(svgDom);
284
+ if (raster) {
285
+ __android_log_print(ANDROID_LOG_DEBUG, "GameMethods",
286
+ "loadImage: parsed as raster id=%.0f", id);
287
+ imageCache[id] = std::move(raster);
288
+ return true;
289
+ }
248
290
 
249
- return true;
291
+ __android_log_print(ANDROID_LOG_ERROR, "GameMethods",
292
+ "loadImage: both SVG parse and raster decode failed "
293
+ "id=%.0f",
294
+ id);
295
+
296
+ return false;
250
297
  });
251
298
  };
252
299
  } // namespace margelo::nitro::rngine
@@ -31,7 +31,7 @@ public:
31
31
  std::shared_ptr<Promise<bool>>
32
32
  loadLottie(double id, const std::string &jsonStr) override;
33
33
 
34
- std::shared_ptr<Promise<bool>> loadSvg(double id,
35
- const std::string &svgUri) override;
34
+ std::shared_ptr<Promise<bool>> loadImage(double id,
35
+ const std::string &svgUri) override;
36
36
  };
37
37
  } // namespace margelo::nitro::rngine
@@ -10,6 +10,7 @@
10
10
  #include "include/core/SkColorSpace.h"
11
11
  #include "include/core/SkPaint.h"
12
12
  #include "include/core/SkRect.h"
13
+ #include "include/core/SkRefCnt.h"
13
14
  #include "include/core/SkSurface.h"
14
15
 
15
16
  #include "include/gpu/ganesh/GrBackendSurface.h"
@@ -19,6 +20,7 @@
19
20
 
20
21
  #include "include/gpu/ganesh/gl/GrGLDirectContext.h"
21
22
  #include "include/gpu/ganesh/gl/GrGLInterface.h"
23
+ #include "modules/svg/include/SkSVGDOM.h"
22
24
 
23
25
  #include <EGL/egl.h>
24
26
  #include <GLES3/gl3.h>
@@ -151,29 +153,63 @@ void GameRenderer::render(const Screen &screen,
151
153
  if (screen.asset.has_value() && screen.asset.value() != 0) {
152
154
  double assetId = screen.asset.value();
153
155
 
154
- auto svgIt = _svgCache.find(assetId);
155
- if (svgIt != _svgCache.end() && svgIt->second) {
156
- auto &svgDom = svgIt->second;
157
-
158
- SkSize intrinsicSize = svgDom->containerSize();
159
- if (intrinsicSize.isEmpty()) {
160
- svgDom->setContainerSize(SkSize::Make(virtualWidth, virtualHeight));
161
- intrinsicSize = SkSize::Make(virtualWidth, virtualHeight);
162
- }
156
+ auto imageIt = _imageCache.find(assetId);
157
+ if (imageIt != _imageCache.end()) {
158
+ std::visit(
159
+ [&](const auto image) {
160
+ using T = std::decay_t<decltype(image)>;
161
+ if constexpr (std::is_same_v<T, sk_sp<SkSVGDOM>>) {
162
+ SkSize intrinsicSize = image->containerSize();
163
+
164
+ if (intrinsicSize.isEmpty()) {
165
+ image->setContainerSize(
166
+ SkSize::Make(virtualWidth, virtualHeight));
167
+ intrinsicSize = SkSize::Make(virtualWidth, virtualHeight);
168
+ }
163
169
 
164
- float scaleX = virtualWidth / intrinsicSize.width();
165
- float scaleY = virtualHeight / intrinsicSize.height();
170
+ float scaleX = virtualWidth / intrinsicSize.width();
171
+ float scaleY = virtualHeight / intrinsicSize.height();
166
172
 
167
- canvas->save();
168
- canvas->scale(scaleX, scaleY);
169
- svgDom->render(canvas);
170
- canvas->restore();
173
+ canvas->save();
174
+ if (screen.flipH.has_value() || screen.flipV.has_value()) {
175
+ canvas->translate(virtualWidth / 2.f, virtualHeight / 2.f);
176
+ canvas->scale(screen.flipH.value_or(false) ? -1.f : 1.f,
177
+ screen.flipV.value_or(false) ? -1.f : 1.f);
178
+ canvas->translate(-virtualWidth / 2.f, -virtualHeight / 2.f);
179
+ }
180
+ canvas->scale(scaleX, scaleY);
181
+ image->render(canvas);
182
+ canvas->restore();
183
+ } else {
184
+ float intrinsicW = static_cast<float>(image->width());
185
+ float intrinsicH = static_cast<float>(image->height());
186
+ if (intrinsicW <= 0.f || intrinsicH <= 0.f)
187
+ return;
188
+
189
+ float scaleX = virtualWidth / intrinsicW;
190
+ float scaleY = virtualHeight / intrinsicH;
191
+
192
+ canvas->save();
193
+ if (screen.flipH.has_value() || screen.flipV.has_value()) {
194
+ canvas->translate(virtualWidth / 2.f, virtualHeight / 2.f);
195
+ canvas->scale(screen.flipH.value_or(false) ? -1.f : 1.f,
196
+ screen.flipV.value_or(false) ? -1.f : 1.f);
197
+ canvas->translate(-virtualWidth / 2.f, -virtualHeight / 2.f);
198
+ }
199
+ canvas->scale(scaleX, scaleY);
200
+
201
+ SkSamplingOptions sampling(SkFilterMode::kLinear,
202
+ SkMipmapMode::kLinear);
203
+ canvas->drawImage(image, 0.f, 0.f, sampling);
204
+ canvas->restore();
205
+ }
206
+ },
207
+ imageIt->second);
171
208
  } else {
172
209
  auto lottieIt = _lottieCache.find(assetId);
173
210
  if (lottieIt != _lottieCache.end() && lottieIt->second) {
174
211
  auto &lottie = lottieIt->second;
175
- lottie->seekFrameTime(screen.progress.value_or(0.0) *
176
- lottie->duration());
212
+ lottie->seek(screen.progress.value_or(0.0));
177
213
  SkRect dstBounds = SkRect::MakeWH(virtualWidth, virtualHeight);
178
214
  lottie->render(canvas, &dstBounds);
179
215
  }
@@ -234,29 +270,55 @@ void GameRenderer::render(const Screen &screen,
234
270
  SkAutoCanvasRestore autoRestore(canvas, true);
235
271
  canvas->translate(px - width / 2, py - height / 2);
236
272
 
237
- auto svgIt = _svgCache.find(assetId);
238
- if (svgIt != _svgCache.end() && svgIt->second) {
239
- auto &svgDom = svgIt->second;
240
-
241
- SkSize intrinsicSize = svgDom->containerSize();
242
- if (intrinsicSize.isEmpty()) {
243
- svgDom->setContainerSize(SkSize::Make(width, height));
244
- intrinsicSize = SkSize::Make(width, height);
245
- }
246
-
247
- float scaleX = width / intrinsicSize.width();
248
- float scaleY = height / intrinsicSize.height();
273
+ if (entity.flipH.has_value() || entity.flipV.has_value()) {
274
+ canvas->translate(width / 2.f, height / 2.f);
275
+ canvas->scale(entity.flipH.value_or(false) ? -1.f : 1.f,
276
+ entity.flipV.value_or(false) ? -1.f : 1.f);
277
+ canvas->translate(-width / 2.f, -height / 2.f);
278
+ }
249
279
 
250
- canvas->save();
251
- canvas->scale(scaleX, scaleY);
252
- svgDom->render(canvas);
253
- canvas->restore();
280
+ auto imageIt = _imageCache.find(assetId);
281
+ if (imageIt != _imageCache.end()) {
282
+ std::visit(
283
+ [&](const auto image) {
284
+ using T = std::decay_t<decltype(image)>;
285
+ if constexpr (std::is_same_v<T, sk_sp<SkSVGDOM>>) {
286
+ SkSize intrinsicSize = image->containerSize();
287
+ if (intrinsicSize.isEmpty()) {
288
+ image->setContainerSize(SkSize::Make(width, height));
289
+ intrinsicSize = SkSize::Make(width, height);
290
+ }
291
+
292
+ float scaleX = width / intrinsicSize.width();
293
+ float scaleY = height / intrinsicSize.height();
294
+
295
+ canvas->save();
296
+ canvas->scale(scaleX, scaleY);
297
+ image->render(canvas);
298
+ canvas->restore();
299
+ } else {
300
+ float intrinsicW = static_cast<float>(image->width());
301
+ float intrinsicH = static_cast<float>(image->height());
302
+ if (intrinsicW <= 0.f || intrinsicH <= 0.f)
303
+ return;
304
+
305
+ float scaleX = width / intrinsicW;
306
+ float scaleY = height / intrinsicH;
307
+
308
+ canvas->save();
309
+ canvas->scale(scaleX, scaleY);
310
+ SkSamplingOptions sampling(SkFilterMode::kLinear,
311
+ SkMipmapMode::kLinear);
312
+ canvas->drawImage(image, 0.f, 0.f, sampling);
313
+ canvas->restore();
314
+ }
315
+ },
316
+ imageIt->second);
254
317
  } else {
255
318
  auto lottieIt = _lottieCache.find(assetId);
256
319
  if (lottieIt != _lottieCache.end() && lottieIt->second) {
257
320
  auto &lottie = lottieIt->second;
258
- lottie->seekFrameTime(entity.progress.value_or(0.0) *
259
- lottie->duration());
321
+ lottie->seek(entity.progress.value_or(0.0));
260
322
  SkRect dstBounds = SkRect::MakeWH(width, height);
261
323
  lottie->render(canvas, &dstBounds);
262
324
  }
@@ -1,6 +1,7 @@
1
1
  #pragma once
2
2
  #include "Entity.hpp"
3
3
  #include "Screen.hpp"
4
+ #include "include/core/SkImage.h"
4
5
  #include "include/core/SkSurface.h"
5
6
  #include "include/gpu/ganesh/GrDirectContext.h"
6
7
  #include "modules/skottie/include/Skottie.h"
@@ -21,9 +22,11 @@ public:
21
22
 
22
23
  ~GameRenderer();
23
24
 
24
- std::map<double, sk_sp<SkSVGDOM>> &getSvgCacheInternal() {
25
- return _svgCache;
25
+ std::map<double, std::variant<sk_sp<SkSVGDOM>, sk_sp<SkImage>>> &
26
+ getImageCacheInternal() {
27
+ return _imageCache;
26
28
  };
29
+
27
30
  std::map<double, sk_sp<skottie::Animation>> &getLottieCacheInternal() {
28
31
  return _lottieCache;
29
32
  };
@@ -52,8 +55,8 @@ private:
52
55
  int _height{0};
53
56
  bool _initialized{false};
54
57
 
55
- std::map<double, sk_sp<SkSVGDOM>> _svgCache;
56
58
  std::map<double, sk_sp<skottie::Animation>> _lottieCache;
59
+ std::map<double, std::variant<sk_sp<SkSVGDOM>, sk_sp<SkImage>>> _imageCache;
57
60
 
58
61
  bool isEntityVisible(const Entity &entity, float screenWidth,
59
62
  float screenHeight);
@@ -24,7 +24,7 @@ interface GameMethods extends HybridObject<{
24
24
 
25
25
  isAssetLoaded(id: number): boolean;
26
26
  loadLottie(id: number, jsonStr: string): Promise<boolean>;
27
- loadSvg(id: number, svgUri: string): Promise<boolean>;
27
+ loadImage(id: number, imageUri: string): Promise<boolean>;
28
28
  }
29
29
 
30
30
  export const gameMethods =
@@ -89,9 +89,9 @@ const loadAsset = async (asset: unknown) => {
89
89
  if (!assetUri) {
90
90
  throw new Error(`loadAssets: could not resolve asset URI for ${asset}`);
91
91
  }
92
- const isSvgLoaded = await gameMethods.loadSvg(asset, assetUri);
93
- if (!isSvgLoaded) {
94
- throw new Error('loadAssets: Failed to load svg asset');
92
+ const isLoaded = await gameMethods.loadImage(asset, assetUri);
93
+ if (!isLoaded) {
94
+ throw new Error('loadAssets: Failed to load image asset');
95
95
  }
96
96
  return asset;
97
97
  }
@@ -29,8 +29,14 @@ interface Renderable {
29
29
  color?: string;
30
30
  /** Asset to render, use `require` with the file path to get the id. */
31
31
  asset?: number;
32
+ /** Whether to flip the rendered asset horizontally. */
33
+ flipH?: boolean;
34
+ /** Whether to flip the rendered asset vertically. */
35
+ flipV?: boolean;
32
36
  /** Animation progress between 0 and 1, automatically advanced each tick for Lottie assets. */
33
37
  progress?: number;
38
+ /** Playback speed multiplier for animated assets (1 = normal speed). */
39
+ speed?: number;
34
40
  }
35
41
 
36
42
  interface Kinematic {
@@ -1,24 +0,0 @@
1
- package com.margelo.nitro.rngine
2
-
3
- import androidx.annotation.Keep
4
- import com.margelo.nitro.NitroModules
5
- import java.net.URL
6
-
7
- @Keep
8
- object SvgLoaderHelper {
9
- @JvmStatic
10
- fun loadFromUrl(uri: String): ByteArray {
11
- return URL(uri).openStream().use { it.readBytes() }
12
- }
13
-
14
- @JvmStatic
15
- fun loadFromResource(uri: String): ByteArray {
16
- val context = NitroModules.applicationContext
17
- ?: throw IllegalStateException("No Context available!")
18
- val resId = context.resources.getIdentifier(uri, "raw", context.packageName)
19
- if (resId == 0) {
20
- throw IllegalStateException("Could not resolve raw resource for asset: $uri")
21
- }
22
- return context.resources.openRawResource(resId).use { it.readBytes() }
23
- }
24
- }