hiloteam / Hilo

A Cross-end HTML5 Game development solution
https://hiloteam.github.io/
MIT License
5.93k stars 863 forks source link

Graphics 性能的问题 #118

Closed xiangfengsu closed 6 years ago

xiangfengsu commented 6 years ago

要做个画板功能,画的速度越快,fps 掉的很厉害, demo

` var _self = this; var drawingBoard = new Hilo.Container({ x: 0, y: 0, width: _self.width, height: 600,

        });
        var butClear = new Hilo.View({
            x: 0,
            y: 610,
            width: 200,
            height: 200,
            background: 'red'
        });

        var graphics = new Hilo.Graphics({
            x: 0,
            y: 0,
            width: _self.width,
            height: 600
        }).addTo(drawingBoard);
        graphics.lineStyle(4, "#02d1d1", 1, 'round', 'round');
        drawingBoard.on(Hilo.event.POINTER_START, function (e) {
            graphics.moveTo(e.stageX, e.stageY);
        });
        drawingBoard.on(Hilo.event.POINTER_MOVE, function (e) {
            graphics.lineTo(e.stageX, e.stageY);
            graphics.endFill();
        });
        butClear.on(Hilo.event.POINTER_START, function () {
            graphics.clear();
            graphics.lineStyle(4, "#02d1d1", 1, 'round', 'round');
        })

        _self.stage.addChild(drawingBoard, butClear);`

image image image

06wj commented 6 years ago

可以参考这个写下 https://github.com/hiloteam/Hilo/blob/dev/examples/blendMode.html#L56

demo

xiangfengsu commented 6 years ago

@06wj 谢谢了~ ~