Open jcyuan opened 5 years ago
actually RenderTexture inherits from GameObject
which already has this member.
to dispatch event:
this.emit(....)
better to have a cache to store these pieces, otherwise if update the niceslice frequently there will be a lot of js GC.
and, should call this.scene.make.image({...}, false)
, to avoid add these pieces into the displayList
. I'm not sure if this is a bug in Phaser, make
should not add thing into the scene by default, but unfortunately the default value is true
if missing.
should pass all the pieces as an array into this method to do the batch drawing.
if (!foundInCache) {
frameImage = this.scene.make.image({
key: this.sourceTex.key,
frame: curFrame.name
}).setOrigin(0)
}
else frameImage = cache.get(frame.name)
// then refresh features
const scaleX = wantWidth / curFrame.width
const scaleY = wantHeight / curFrame.height
frameImage
.setPosition(x, y) // store XY into it then later the batch drawing will use them automatically
.setScale(scaleX, scaleY)
// -------
// call in the `drawFrames` method but not in the temporary `draw` method
this.draw([ all image pieces ]) // without x, y
I mean the file size. even minimized it still has 12kb. our environment only has 4mb space, and Phaser takes 800+kb. I think for the murmurhash we can just use a sequenced number (static member) instead to generate the frame name.
besides, it's better to not
eval
things when combine all files using webpack, this makes the source file really hard to read when debugging and use it as the source.