isaacscript-common 30.5.5 → 30.6.0

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.
@@ -12883,6 +12883,15 @@ export declare function newRNG(seed?: Seed): RNG;
12883
12883
  */
12884
12884
  export declare function newRoom(seedOrRNG?: Seed | RNG): int | undefined;
12885
12885
 
12886
+ /**
12887
+ * Helper function to load a new sprite and play its default animation.
12888
+ *
12889
+ * @param anm2Path The path to the "anm2" file that should be loaded.
12890
+ * @param pngPath Optional. The path to a custom PNG file that should be loaded on layer 0 of the
12891
+ * sprite.
12892
+ */
12893
+ export declare function newSprite(anm2Path: string, pngPath?: string): Sprite;
12894
+
12886
12895
  /**
12887
12896
  * Helper function to generate a new sprite based on a collectible. If the provided collectible type
12888
12897
  * is invalid, a sprite with a Curse of the Blind question mark will be returned.
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 30.5.5
3
+ isaacscript-common 30.6.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -20714,6 +20714,19 @@ function ____exports.getLastFrameOfAnimation(self, sprite, animation)
20714
20714
  sprite:SetFrame(currentFrame)
20715
20715
  return finalFrame
20716
20716
  end
20717
+ function ____exports.newSprite(self, anm2Path, pngPath)
20718
+ local sprite = Sprite()
20719
+ if pngPath == nil then
20720
+ sprite:Load(anm2Path, true)
20721
+ else
20722
+ sprite:Load(anm2Path, false)
20723
+ sprite:ReplaceSpritesheet(0, pngPath)
20724
+ sprite:LoadGraphics()
20725
+ end
20726
+ local defaultAnimation = sprite:GetDefaultAnimation()
20727
+ sprite:Play(defaultAnimation, true)
20728
+ return sprite
20729
+ end
20717
20730
  function ____exports.setSpriteOpacity(self, sprite, alpha)
20718
20731
  local fadedColor = copyColor(nil, sprite.Color)
20719
20732
  fadedColor.A = alpha
@@ -32,6 +32,14 @@ export declare function clearSprite(sprite: Sprite, ...layerIDs: int[]): void;
32
32
  * player animations.
33
33
  */
34
34
  export declare function getLastFrameOfAnimation(sprite: Sprite, animation?: string): int;
35
+ /**
36
+ * Helper function to load a new sprite and play its default animation.
37
+ *
38
+ * @param anm2Path The path to the "anm2" file that should be loaded.
39
+ * @param pngPath Optional. The path to a custom PNG file that should be loaded on layer 0 of the
40
+ * sprite.
41
+ */
42
+ export declare function newSprite(anm2Path: string, pngPath?: string): Sprite;
35
43
  /**
36
44
  * Helper function to keep a sprite's color the same values as it already is but set the opacity to
37
45
  * a specific value.
@@ -1 +1 @@
1
- {"version":3,"file":"sprites.d.ts","sourceRoot":"","sources":["../../../src/functions/sprites.ts"],"names":[],"mappings":";;;AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,EAAE,GAAG,IAAI,CAWpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,GAAG,CAmBL;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAInE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,EACf,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,GACd,OAAO,CAaT;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,GAAG,GACX,OAAO,CAIT"}
1
+ {"version":3,"file":"sprites.d.ts","sourceRoot":"","sources":["../../../src/functions/sprites.ts"],"names":[],"mappings":";;;AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,EAAE,GAAG,IAAI,CAWpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,GAAG,CAmBL;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAepE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAInE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,EACf,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,GACd,OAAO,CAaT;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,GAAG,GACX,OAAO,CAIT"}
@@ -64,6 +64,24 @@ function ____exports.getLastFrameOfAnimation(self, sprite, animation)
64
64
  sprite:SetFrame(currentFrame)
65
65
  return finalFrame
66
66
  end
67
+ --- Helper function to load a new sprite and play its default animation.
68
+ --
69
+ -- @param anm2Path The path to the "anm2" file that should be loaded.
70
+ -- @param pngPath Optional. The path to a custom PNG file that should be loaded on layer 0 of the
71
+ -- sprite.
72
+ function ____exports.newSprite(self, anm2Path, pngPath)
73
+ local sprite = Sprite()
74
+ if pngPath == nil then
75
+ sprite:Load(anm2Path, true)
76
+ else
77
+ sprite:Load(anm2Path, false)
78
+ sprite:ReplaceSpritesheet(0, pngPath)
79
+ sprite:LoadGraphics()
80
+ end
81
+ local defaultAnimation = sprite:GetDefaultAnimation()
82
+ sprite:Play(defaultAnimation, true)
83
+ return sprite
84
+ end
67
85
  --- Helper function to keep a sprite's color the same values as it already is but set the opacity to
68
86
  -- a specific value.
69
87
  --
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "30.5.5",
3
+ "version": "30.6.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -69,6 +69,30 @@ export function getLastFrameOfAnimation(
69
69
  return finalFrame;
70
70
  }
71
71
 
72
+ /**
73
+ * Helper function to load a new sprite and play its default animation.
74
+ *
75
+ * @param anm2Path The path to the "anm2" file that should be loaded.
76
+ * @param pngPath Optional. The path to a custom PNG file that should be loaded on layer 0 of the
77
+ * sprite.
78
+ */
79
+ export function newSprite(anm2Path: string, pngPath?: string): Sprite {
80
+ const sprite = Sprite();
81
+
82
+ if (pngPath === undefined) {
83
+ sprite.Load(anm2Path, true);
84
+ } else {
85
+ sprite.Load(anm2Path, false);
86
+ sprite.ReplaceSpritesheet(0, pngPath);
87
+ sprite.LoadGraphics();
88
+ }
89
+
90
+ const defaultAnimation = sprite.GetDefaultAnimation();
91
+ sprite.Play(defaultAnimation, true);
92
+
93
+ return sprite;
94
+ }
95
+
72
96
  /**
73
97
  * Helper function to keep a sprite's color the same values as it already is but set the opacity to
74
98
  * a specific value.