let downButton = this.add.image(70, 530, 'down').setInteractive() let upButton = this.add.image(730, 530, 'up').setInteractive() // setInteractive() // https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Image.html let tweens = this.tweens
this.input.on('gameobjectup', (pointer, gameobject) => { // Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. // 1 代表真实运行速度 倍数形式 动画的duration不会受到影响,这仅仅是在运行时的调整。 if (gameobject === downButton && tweens.timeScale > 0) { tweens.pauseAll() } elseif (gameobject === upButton && tweens.timeScale < 9.9) { tweens.resumeAll() } })
lottie.loadAnimation({ container: element, // the dom element that will contain the animation renderer: 'svg', loop: true, autoplay: true, path: 'data.json' // the path to the animation json })
我实际使用的代码是
1 2 3 4 5 6 7
lottie.loadAnimation({ container: this.$refs.animationHeart, // the dom element that will contain the animation renderer: 'svg', loop: true, autoplay: true, path: path.join(__dirname, './4265-favoriete-producten.json') // the path to the animation json })
报错:
Uncaught DOMException: Failed to read the ‘responseText’ property from ‘XMLHttpRequest’: The value is only accessible if the object’s ‘responseType’ is ‘’ or ‘text’ (was ‘json’). at formatResponse (webpack-internal:///./node_modules/_lottie-web@5.4.4@lottie-web/build/player/lottie.js:4325:17) at XMLHttpRequest.xhr.onreadystatechange (webpack-internal:///./node_modules/_lottie-web@5.4.4@lottie-web/build/player/lottie.js:4340:26)
var ints = path1.getIntersections(path2) console.log(ints.length)
var colors = [“red”, “green”, “orange”]; for (var i = 0; i < ints.length; i++) { var p = new Path.Circle({radius: 5, fillColor: colors[i]}); p.position = ints[i].point; }
就是通过一个getIntersections的方法来获取相交的点
如何改变fillColor?(动画)
1
path.fillColor.hue += 1;
如何添加文字?
[]
1 2 3 4 5 6 7
var text = new PointText({ point: view.center, justification: 'center', fontSize: 10, fillColor: 'red' }) text.content = 'asd'