Class in reactor_sprites.js

Sprite_Enemy

54 public functions in 6 groups · show internal (_) functions

The main menu, drawn by Scenes and Windows.

Familiar territory. Sprite_Enemy keeps the RPG Maker MZ API, so existing MZ knowledge, tutorials and plugin code apply. Reactor's additions are marked with descriptions below.

Quick Reference

Setup & Creation 8

initialize() Sets up a new instance.
initMembers() Initializes the members.
createStateIconSprite() Creates the state icon sprite.
loadBitmap() Loads the bitmap.
initVisibility() Initializes the visibility.
setupEffect() Setup effect.
createFragmentCollapse() The battler cut into triangles that fly apart: glass, not grit.
createParticleCollapse() Creates the particle collapse.

Checks (True / False) 2

isEffecting() Whether it is effecting.
isParticleCollapseCellVisible() Whether it is particle collapse cell visible.

Actions 14

setBattler() Sets the battler.
setHue() Sets the hue.
startEffect() Starts the effect.
startAppear() Starts the appear.
startDisappear() Starts the disappear.
startWhiten() Starts the whiten.
startBlink() Starts the blink.
startCollapse() Starts the collapse.
startBossCollapse() Starts the boss collapse.
startInstantCollapse() Starts the instant collapse.
startCorpseCollapse() Starts the corpse collapse.
startCorpseRise() Starts the corpse rise.
startParticleCollapse() Starts the particle collapse.
destroyParticleCollapse() Destroy particle collapse.

Events, Commands & Input 1

emitParticleCollapseSpark() Emit particle collapse spark.

Updating & Drawing 18

update() Update.
updateBitmap() Updates the bitmap each frame.
updateFrame() Updates the frame each frame.
updatePosition() Updates the position each frame.
updateStateSprite() Updates the state sprite each frame.
updateEffect() Updates the effect each frame.
updateWhiten() Updates the whiten each frame.
updateBlink() Updates the blink each frame.
updateAppear() Updates the appear each frame.
updateDisappear() Updates the disappear each frame.
updateCollapse() Updates the collapse each frame.
updateBossCollapse() Updates the boss collapse each frame.
updateInstantCollapse() Updates the instant collapse each frame.
updateCorpseCollapse() Updates the corpse collapse each frame.
updateCorpseRise() Updates the corpse rise each frame.
updateFragmentCollapse() Move every triangle: thrown out from the middle, turning about its own, falling, and stopped by the floor the…
updateParticleCollapse() Updates the particle collapse each frame.
updateParticleCollapseSparks() Updates the particle collapse sparks each frame.

Other 11

revertToNormal() Revert to normal.
layCorpse() Lays the sprite amount of the way down: 0 standing, 1 flat.
particleCollapseArtSprite() The descendant that actually carries the battler art.
particleCollapseArtOffset() Where the art sprite sits in this sprite's own coordinates, so the particles can stand in for it exactly howe…
particleCollapseAlphaMap() Per-pixel alpha for a texture source, cached on the source itself.
particleCollapseSparkTexture() The soft blob a spark is drawn with, built once per distinct gradient.
blendParticleCollapseTint() Blend particle collapse tint.
particleCollapseRoll() Reads a [min, max] preset range, tolerating a missing or malformed one.
unhookParticleCollapseTextures() Unhooks a collapse's shard textures from the shared battler source at once.
damageOffsetX() Damage offset x.
damageOffsetY() Damage offset y.

Setup & Creation

initialize

method source
Sprite_Enemy.prototype.initialize(battler)

Sets up a new instance. (Same as the RPG Maker MZ method of this name.)

initMembers

method source
Sprite_Enemy.prototype.initMembers()

Initializes the members. (Same as the RPG Maker MZ method of this name.)

createStateIconSprite

method source
Sprite_Enemy.prototype.createStateIconSprite()

Creates the state icon sprite. (Same as the RPG Maker MZ method of this name.)

loadBitmap

method source
Sprite_Enemy.prototype.loadBitmap(name)

Loads the bitmap. (Same as the RPG Maker MZ method of this name.)

initVisibility

method source
Sprite_Enemy.prototype.initVisibility()

Initializes the visibility. (Same as the RPG Maker MZ method of this name.)

setupEffect

method source
Sprite_Enemy.prototype.setupEffect()

Setup effect. (Same as the RPG Maker MZ method of this name.)

createFragmentCollapse

method source
Sprite_Enemy.prototype.createFragmentCollapse(preset)

The battler cut into triangles that fly apart: glass, not grit.

Details

The battler cut into triangles that fly apart: glass, not grit.

A particle is a quad however small it is cut, so a break made of them reads as chunks. Real shards need real polygons, so this path builds one PIXI.Mesh whose triangles are cut from the battler's own frame -- a jittered grid, each cell split on a random diagonal, so no two pieces are the same shape -- and moves their corners itself each frame. One mesh is one draw call, and a few hundred triangles cost less arithmetic per frame than the particle path.

@param
preset object A PARTICLE_COLLAPSE entry carrying fragments.
@returns
?object The collapse state, or null if it cannot be built.

createParticleCollapse

method source
Sprite_Enemy.prototype.createParticleCollapse(preset)

Creates the particle collapse. (Same as the RPG Maker MZ method of this name.)

Checks (True / False)

isEffecting

method source
Sprite_Enemy.prototype.isEffecting()

Whether it is effecting. (Same as the RPG Maker MZ method of this name.)

isParticleCollapseCellVisible

method source
Sprite_Enemy.prototype.isParticleCollapseCellVisible(map, width, x, y, w, h)

Whether it is particle collapse cell visible. (Same as the RPG Maker MZ method of this name.)

Actions

setBattler

method source
Sprite_Enemy.prototype.setBattler(battler)

Sets the battler. (Same as the RPG Maker MZ method of this name.)

setHue

method source
Sprite_Enemy.prototype.setHue(hue)

Sets the hue. (Same as the RPG Maker MZ method of this name.)

startEffect

method source
Sprite_Enemy.prototype.startEffect(effectType)

Starts the effect. (Same as the RPG Maker MZ method of this name.)

startAppear

method source
Sprite_Enemy.prototype.startAppear()

Starts the appear. (Same as the RPG Maker MZ method of this name.)

startDisappear

method source
Sprite_Enemy.prototype.startDisappear()

Starts the disappear. (Same as the RPG Maker MZ method of this name.)

startWhiten

method source
Sprite_Enemy.prototype.startWhiten()

Starts the whiten. (Same as the RPG Maker MZ method of this name.)

startCollapse

method source
Sprite_Enemy.prototype.startCollapse()

Starts the collapse. (Same as the RPG Maker MZ method of this name.)

startBossCollapse

method source
Sprite_Enemy.prototype.startBossCollapse()

Starts the boss collapse. (Same as the RPG Maker MZ method of this name.)

startInstantCollapse

method source
Sprite_Enemy.prototype.startInstantCollapse()

Starts the instant collapse. (Same as the RPG Maker MZ method of this name.)

startCorpseCollapse

method source
Sprite_Enemy.prototype.startCorpseCollapse()

Starts the corpse collapse. (Same as the RPG Maker MZ method of this name.)

startCorpseRise

method source
Sprite_Enemy.prototype.startCorpseRise()

Starts the corpse rise. (Same as the RPG Maker MZ method of this name.)

startParticleCollapse

method source
Sprite_Enemy.prototype.startParticleCollapse(presetName)

Starts the particle collapse. (Same as the RPG Maker MZ method of this name.)

destroyParticleCollapse

method source
Sprite_Enemy.prototype.destroyParticleCollapse()

Destroy particle collapse. (Same as the RPG Maker MZ method of this name.)

Events, Commands & Input

emitParticleCollapseSpark

method source
Sprite_Enemy.prototype.emitParticleCollapseSpark(state, x, y)

Emit particle collapse spark. (Same as the RPG Maker MZ method of this name.)

Updating & Drawing

update

method source
Sprite_Enemy.prototype.update()

Update. (Same as the RPG Maker MZ method of this name.)

updateBitmap

method source
Sprite_Enemy.prototype.updateBitmap()

Updates the bitmap each frame. (Same as the RPG Maker MZ method of this name.)

updateFrame

method source
Sprite_Enemy.prototype.updateFrame()

Updates the frame each frame. (Same as the RPG Maker MZ method of this name.)

updatePosition

method source
Sprite_Enemy.prototype.updatePosition()

Updates the position each frame. (Same as the RPG Maker MZ method of this name.)

updateStateSprite

method source
Sprite_Enemy.prototype.updateStateSprite()

Updates the state sprite each frame. (Same as the RPG Maker MZ method of this name.)

updateEffect

method source
Sprite_Enemy.prototype.updateEffect()

Updates the effect each frame. (Same as the RPG Maker MZ method of this name.)

updateWhiten

method source
Sprite_Enemy.prototype.updateWhiten()

Updates the whiten each frame. (Same as the RPG Maker MZ method of this name.)

updateAppear

method source
Sprite_Enemy.prototype.updateAppear()

Updates the appear each frame. (Same as the RPG Maker MZ method of this name.)

updateDisappear

method source
Sprite_Enemy.prototype.updateDisappear()

Updates the disappear each frame. (Same as the RPG Maker MZ method of this name.)

updateCollapse

method source
Sprite_Enemy.prototype.updateCollapse()

Updates the collapse each frame. (Same as the RPG Maker MZ method of this name.)

updateBossCollapse

method source
Sprite_Enemy.prototype.updateBossCollapse()

Updates the boss collapse each frame. (Same as the RPG Maker MZ method of this name.)

updateInstantCollapse

method source
Sprite_Enemy.prototype.updateInstantCollapse()

Updates the instant collapse each frame. (Same as the RPG Maker MZ method of this name.)

updateCorpseCollapse

method source
Sprite_Enemy.prototype.updateCorpseCollapse()

Updates the corpse collapse each frame. (Same as the RPG Maker MZ method of this name.)

updateCorpseRise

method source
Sprite_Enemy.prototype.updateCorpseRise()

Updates the corpse rise each frame. (Same as the RPG Maker MZ method of this name.)

updateFragmentCollapse

method source
Sprite_Enemy.prototype.updateFragmentCollapse(state, elapsed)

Move every triangle: thrown out from the middle, turning about its own, falling, and stopped by the floor the battler stood on.

Details

Move every triangle: thrown out from the middle, turning about its own, falling, and stopped by the floor the battler stood on.

@param
state object The collapse state from createFragmentCollapse.
@param
elapsed number Frames since the collapse began.

updateParticleCollapse

method source
Sprite_Enemy.prototype.updateParticleCollapse()

Updates the particle collapse each frame. (Same as the RPG Maker MZ method of this name.)

updateParticleCollapseSparks

method source
Sprite_Enemy.prototype.updateParticleCollapseSparks(state)

Updates the particle collapse sparks each frame. (Same as the RPG Maker MZ method of this name.)

Other

revertToNormal

method source
Sprite_Enemy.prototype.revertToNormal()

Revert to normal. (Same as the RPG Maker MZ method of this name.)

layCorpse

method source
Sprite_Enemy.prototype.layCorpse(amount)

Lays the sprite amount of the way down: 0 standing, 1 flat.

particleCollapseArtSprite

method source
Sprite_Enemy.prototype.particleCollapseArtSprite()

The descendant that actually carries the battler art.

Details

The descendant that actually carries the battler art.

mainSprite() is not it, whatever its name suggests: VisuStella's Battle Core parents the art under a distortion sprite and returns THAT, so mainSprite() itself holds no bitmap and a collapse reading it would fall back for every enemy in any project running Battle Core. In a stock project mainSprite() is this sprite, and does hold one.

@returns
Sprite|null The sprite holding a ready bitmap, or null.

particleCollapseArtOffset

method source
Sprite_Enemy.prototype.particleCollapseArtOffset(art)

Where the art sprite sits in this sprite's own coordinates, so the particles can stand in for it exactly however deeply Battle Core has nested it.

Details

Where the art sprite sits in this sprite's own coordinates, so the particles can stand in for it exactly however deeply Battle Core has nested it.

@param
art Sprite The sprite returned by particleCollapseArtSprite.
@returns
object An {x, y} offset.

particleCollapseAlphaMap

method source
Sprite_Enemy.prototype.particleCollapseAlphaMap(source, width, height)

Per-pixel alpha for a texture source, cached on the source itself.

Details

Per-pixel alpha for a texture source, cached on the source itself.

Read through the source's own resource rather than Bitmap#context: the context getter calls _ensureCanvas(), which on an image-backed bitmap builds a canvas AND replaces the bitmap's base texture, re-uploading a cached, shared battler image as a side effect of somebody dying.

@param
source object The PIXI texture source behind the battler bitmap.
@param
width number The bitmap width in pixels.
@param
height number The bitmap height in pixels.
@returns
Uint8Array|null One alpha byte per pixel, or null if unreadable.

particleCollapseSparkTexture

static source
Sprite_Enemy.particleCollapseSparkTexture(stops)

The soft blob a spark is drawn with, built once per distinct gradient.

Details

The soft blob a spark is drawn with, built once per distinct gradient.

Cached by the stops themselves rather than by preset name, so two presets sharing a gradient share one texture and a tuned preset gets its own. The bitmaps are held on the class because each texture only borrows its source.

@param
stops Array [offset, css colour] pairs, or null for the default.
@returns
PIXI.Texture The blob texture.

blendParticleCollapseTint

static source
Sprite_Enemy.blendParticleCollapseTint(from, to, rate)

Blend particle collapse tint. (Same as the RPG Maker MZ method of this name.)

particleCollapseRoll

static source
Sprite_Enemy.particleCollapseRoll(range, min, max)

Reads a [min, max] preset range, tolerating a missing or malformed one.

Details

Reads a [min, max] preset range, tolerating a missing or malformed one.

@param
range Array The [min, max] pair.
@param
min number Fallback minimum.
@param
max number Fallback maximum.
@returns
number A value in the range.

unhookParticleCollapseTextures

method source
Sprite_Enemy.prototype.unhookParticleCollapseTextures(shards)

Unhooks a collapse's shard textures from the shared battler source at once.

Details

Unhooks a collapse's shard textures from the shared battler source at once.

Every v8 Texture listens for its source's "resize", and EventEmitter3 removes a listener by rescanning and rebuilding the whole listener array -- so dropping the shards one at a time is quadratic in shard count, and it all lands on the single frame the collapse ends. Measured on this PIXI build with a 370x435 battler: 6,305 shards cost 51.0 ms that way and 11,049 cost 146.8 ms. Filtering them out in one pass is linear -- 0.5 ms and 0.6 ms for the same two grids -- and leaves the source holding exactly the same listeners afterwards.

The listeners that stay -- this battler's own sprite, and any other enemy of the same kind collapsing beside it -- are handed back for the caller to put right rather than written straight back, because Texture.destroy() still calls off("resize") once per shard and EventEmitter3 rebuilds that array on every one of those calls. An empty array left in their place costs one rebuild of nothing, after which the event is gone and each remaining off() returns at its first line. Six 350x299 Dragons at 8,400 shards each cost 3,025 ms between them with the survivors in place, and 17.7 ms with them held aside.

This reaches into EventEmitter3's own storage, so each shape it can hold is checked and an unfamiliar one just leaves the per-texture path to do its job.

@param
shards Array The collapse's shard records.
@returns
?function(): void Puts the held listeners back, or null when there was nothing to hold aside.

damageOffsetX

method source
Sprite_Enemy.prototype.damageOffsetX()

Damage offset x. (Same as the RPG Maker MZ method of this name.)

damageOffsetY

method source
Sprite_Enemy.prototype.damageOffsetY()

Damage offset y. (Same as the RPG Maker MZ method of this name.)