Commit 5a7d96ae authored by haiyoucuv's avatar haiyoucuv

磁铁动画

parent b1f8c571
...@@ -75,8 +75,10 @@ export class Snake extends Container { ...@@ -75,8 +75,10 @@ export class Snake extends Container {
// 创建身体节点 // 创建身体节点
this.addEnergy(GameConfig.initEnergy); this.addEnergy(GameConfig.initEnergy);
this.magnetSp = this.addChild(new Sprite(Assets.get("磁铁范围.png"))); this.magnetSp = this.head.addChild(new Sprite(Assets.get("磁铁范围.png")));
this.magnetSp.anchor.set(0.5, 0.5); this.magnetSp.anchor.set(0.5, 0.5);
const w = 46 * GameConfig.magnetScale + 15;
this.magnetSp.setSize(w, w);
Tween.get(this.magnetSp, { loop: true }) Tween.get(this.magnetSp, { loop: true })
.to({ angle: 360 }, 1000); .to({ angle: 360 }, 1000);
this.magnetSp.visible = false; this.magnetSp.visible = false;
...@@ -110,9 +112,6 @@ export class Snake extends Container { ...@@ -110,9 +112,6 @@ export class Snake extends Container {
let scale = this.bodyScale; let scale = this.bodyScale;
if (this.magnetInfo.time) { if (this.magnetInfo.time) {
scale *= GameConfig.magnetScale; scale *= GameConfig.magnetScale;
this.magnetSp.width = 46 * scale + 15;
this.magnetSp.height = 46 * scale + 15;
this.magnetSp.position.set(this.head.x, this.head.y);
} }
this.collider.setScale(scale, scale); this.collider.setScale(scale, scale);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment