功能修复
This commit is contained in:
1 parent
fed1015849
commit
bae179eb93
13 files changed
+274
-81
No files matched your search
@@ -122,6 +122,45 @@ if (delayedTarget.activeCount !== 0) throw new Error('子发射器延迟未到
|
||||
delayedTarget.update(0.1)
|
||||
if (delayedTarget.activeCount !== 2) throw new Error(`子发射器延迟后应生成 2 颗,实际 ${delayedTarget.activeCount} 颗`)
|
||||
|
||||
// 持续子发射器:每次父事件启动独立窗口,窗口内所有粒子复用该事件的继承快照。
|
||||
const streamConfig = makeConfig({
|
||||
mode: 'stream',
|
||||
streamBehavior: 'normal',
|
||||
rate: 30,
|
||||
duration: 0.1,
|
||||
lifeMin: 1,
|
||||
lifeMax: 1,
|
||||
scaleMode: 'fixed',
|
||||
scaleMin: 1,
|
||||
scaleMax: 1,
|
||||
initialRotationMode: 'fixed',
|
||||
initialRotationMin: 0,
|
||||
initialRotationMax: 0,
|
||||
})
|
||||
streamConfig.imageResources[0].colorMode = 'fixed'
|
||||
streamConfig.imageResources[0].colorStart = '#102030'
|
||||
const streamTarget = new ParticleEmitter(streamConfig)
|
||||
streamTarget.setAutoEmission(false)
|
||||
const streamInheritAttributes = ['color', 'scale', 'rotation', 'life']
|
||||
const streamInheritData = { colorHex: 0x778899, scaleX: 2, scaleY: 2, rotation: 90, life: 0.5 }
|
||||
streamTarget.spawnEventParticle(5, 6, 1, {
|
||||
attributes: streamInheritAttributes,
|
||||
colorMode: 'replace',
|
||||
data: streamInheritData,
|
||||
})
|
||||
streamInheritAttributes.length = 0
|
||||
streamInheritData.colorHex = 0
|
||||
for (let i = 0; i < 3; i++) streamTarget.update(step)
|
||||
const streamStates = streamTarget.capture()
|
||||
if (streamStates.length !== 3) throw new Error(`持续子发射器应按速率生成 3 颗,实际 ${streamStates.length} 颗`)
|
||||
for (const state of streamStates) {
|
||||
if (state.colorHex !== 0x778899 || state.scaleX !== 2 || state.scaleY !== 2 || Math.abs(state.rotation - 90) > 1e-6) {
|
||||
throw new Error('持续发射窗口没有复用父事件的继承快照')
|
||||
}
|
||||
}
|
||||
streamTarget.update(step)
|
||||
if (streamTarget.capture().length !== 3) throw new Error('持续发射窗口结束后仍继续生成粒子')
|
||||
|
||||
// 子发射器:被引用后不自动发射,只接收事件粒子;移除引用后恢复普通系统。
|
||||
const subEmitter = new ParticleEmitter(makeConfig({ burstCount: 5 }))
|
||||
subEmitter.setAutoEmission(false)
|
||||
@@ -224,4 +263,4 @@ if (Math.abs(scaledRectHit.worldX + 125.02) > 0.1 || Math.abs(scaledRectHit.worl
|
||||
throw new Error(`非等比矩形吸附面错误:实际命中 (${scaledRectHit.worldX}, ${scaledRectHit.worldY})`)
|
||||
}
|
||||
|
||||
console.log('粒子事件校验通过:暖场 / 出生 / 死亡 / 碰撞 / 非等比矩形碰撞面 / 子发射器生成与禁用自动发射 / 属性继承 / 深度上限')
|
||||
console.log('粒子事件校验通过:暖场 / 出生 / 死亡 / 碰撞 / 非等比矩形碰撞面 / 持续发射 / 子发射器生成与禁用自动发射 / 属性继承 / 深度上限')
|
||||
Reference in new issue
Block a user