Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
izure committed Jun 30, 2021
1 parent 9e58eb4 commit 5a20b81
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
25 changes: 25 additions & 0 deletions @common/Phaser/Particle/JetSmoke.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Phaser from 'phaser'

import { DefaultParticle, useRandomPositionEmitterConfig, useRandomRotateEmitterConfig } from './DefaultParticle'

export class JetSmokeParticle extends DefaultParticle {
constructor(scene: Phaser.Scene, x: number, y: number, emitRadius: number = 0, texture: string, config: Phaser.Types.GameObjects.Particles.ParticleEmitterConfig = {}) {
super(
scene,
x,
y,
texture,
{
blendMode: Phaser.BlendModes.MULTIPLY,
lifespan: 1500,
frequency: 50,
speed: 0,
alpha: { start: 1, end: 0 },
scale: { start: 0.3, end: 1 },
...useRandomRotateEmitterConfig(45),
...useRandomPositionEmitterConfig(emitRadius),
...config
}
)
}
}
1 change: 1 addition & 0 deletions @test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class Player extends User {

rocket.fireMissile(betweenAngle, 0.1, 0.01, actors[0])
rocket.particle.addExists('flame', this.scene.particle.addJet(0, 0))
rocket.particle.addExists('smoke', this.scene.particle.addJetSmoke(0, 0))

return {}
})
Expand Down
2 changes: 1 addition & 1 deletion particle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eriengine/plugin-particle",
"version": "1.0.1",
"version": "1.0.2",
"description": "Particle plugin for Phaser 3",
"main": "dist/particle/src/eriengine-core-plugin-particle.js",
"scripts": {
Expand Down
15 changes: 15 additions & 0 deletions particle/src/eriengine-core-plugin-particle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { SparkParticle } from '@common/Phaser/Particle/SparkParticle'
import { BurnParticle } from '@common/Phaser/Particle/BurnParticle'
import { SnowParticle } from '@common/Phaser/Particle/SnowParticle'
import { RainParticle } from '@common/Phaser/Particle/RainParticle'
import { JetSmokeParticle } from '@common/Phaser/Particle/JetSmoke'

import particleGreen from '@assets/particle-green.png'
import particleWhite from '@assets/particle-white.png'
Expand Down Expand Up @@ -132,6 +133,20 @@ class Plugin extends Phaser.Plugins.ScenePlugin {
return particle
}

/**
* 로켓과 같은 추진체에서 나오는 연기 파티클 지역을 생성합니다.
* `emitRadius` 매개변수를 이용하여 파티클이 생성되는 지역의 범위를 설정할 수 있습니다.
* @param x 파티클이 생성될 x좌표입니다.
* @param y 파티클이 생성될 y좌표입니다.
* @param emitRadius 파티클이 생성되는 영역의 범위입니다. 파티클은 이 범위 내에서 랜덤하게 생성될 것입니다.
*/
addJetSmoke(x: number, y: number, emitRadius?: number): JetParticle {
const particle = new JetSmokeParticle(this.scene, x, y, emitRadius, ParticleAsset['particle-smoke'])
this.particleset.add(particle)

return particle
}

/**
* 불똥이 튀는 효과를 내는 파티클 지역을 생성합니다.
* `emitRadius` 매개변수를 이용하여 파티클이 생성되는 지역의 범위를 설정할 수 있습니다.
Expand Down

0 comments on commit 5a20b81

Please sign in to comment.