https://github.com/spritejs/sprite-extend-proton
particle renderer for proton-js
https://github.com/spritejs/sprite-extend-proton
Last synced: 7 months ago
JSON representation
particle renderer for proton-js
- Host: GitHub
- URL: https://github.com/spritejs/sprite-extend-proton
- Owner: spritejs
- Created: 2018-06-12T10:07:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-11-10T02:53:52.000Z (about 5 years ago)
- Last Synced: 2025-02-21T16:48:10.291Z (11 months ago)
- Language: JavaScript
- Size: 837 KB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sprite-extend-proton
This is a spritejs extension for [proton-js](https://github.com/a-jie/Proton).
```html
```
## Quick Start
```html
const {Scene, ProtonRenderer} = spritejs
const container = document.getElementById('container');
const scene = new Scene({
container,
width: 600,
height: 600,
})
const layer = scene.layer('fglayer')
const proton = new Proton()
const emitter = new Proton.Emitter()
// set Rate
emitter.rate = new Proton.Rate(Proton.getSpan(10, 20), 0.1)
// add Initialize
emitter.addInitialize(new Proton.Radius(1, 12))
emitter.addInitialize(new Proton.Life(2, 4))
emitter.addInitialize(new Proton.Velocity(3, Proton.getSpan(0, 360), 'polar'))
// add Behaviour
emitter.addBehaviour(new Proton.Color('#ff0000', 'random'))
emitter.addBehaviour(new Proton.Alpha(1, 0))
// set emitter position
emitter.p.x = layer.canvas.width / 2
emitter.p.y = layer.canvas.height / 2
emitter.emit(5)
// add emitter to the proton
proton.addEmitter(emitter)
// add canvas renderer
const renderer = new ProtonRenderer(layer)
proton.addRenderer(renderer)
// use Euler integration calculation is more accurate (default false)
Proton.USE_CLOCK = false
// proton.update()
function tick() {
requestAnimationFrame(tick)
proton.update()
}
tick()
```
## for SpriteJS v2
The previous version (v0.5.0) is for SpriteJS v2.
```html
```