Commit 0cfdcca7 authored by haiyoucuv's avatar haiyoucuv

重构了种子动画,节省了一点资源

parent 0e6f3db0
This diff is collapsed.
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
"name": "exchangePanel" "name": "exchangePanel"
}, },
{ {
"keys": "btn_仓库.png,btn_兑换记录.png,btn_商店.png,btn_规则.png,btn_领水滴.png,game_bg.jpg,广告.png,用户_bg.png,用户_头像.png,用户_水.png,田_初始.png,田_种植.png,田_选择.png,种植框_bg.png,种植框_left.png,种植框_right.png,种植框_山核桃.png,种植框_开心果.png,种植框_板栗.png,种植框_瓜子.png,种植框_腰果.png,种植框_花生.png,种植框_袋子.png,进度_bg.png,进度_fill.png", "keys": "btn_仓库.png,btn_兑换记录.png,btn_商店.png,btn_规则.png,btn_领水滴.png,game_bg.jpg,广告.png,用户_bg.png,用户_头像.png,用户_水.png,田_初始.png,田_种植.png,田_选择.png,种植框_bg.png,种植框_left.png,种植框_right.png,种植框_time_bg.png,种植框_山核桃.png,种植框_开心果.png,种植框_板栗.png,种植框_瓜子.png,种植框_腰果.png,种植框_花生.png,袋子.png,进度_bg.png,进度_fill.png",
"name": "gameScene" "name": "gameScene"
}, },
{ {
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
"name": "panel" "name": "panel"
}, },
{ {
"keys": "Cashew_0.png,Cashew_1.png,Cashew_2.png,Cashew_seed.png,Chestnut_0.png,Chestnut_1.png,Chestnut_2.png,Chestnut_seed.png,Peanut_0.png,Peanut_1.png,Peanut_2.png,Peanut_seed.png,Pecan_0.png,Pecan_1.png,Pecan_2.png,Pecan_seed.png,Pistachio_0.png,Pistachio_1.png,Pistachio_2.png,Pistachio_seed.png,Sunflower_0.png,Sunflower_1.png,Sunflower_2.png,Sunflower_seed.png", "keys": "Cashew_0.png,Cashew_1.png,Cashew_2.png,Chestnut_0.png,Chestnut_1.png,Chestnut_2.png,Peanut_0.png,Peanut_1.png,Peanut_2.png,Pecan_0.png,Pecan_1.png,Pecan_2.png,Pistachio_0.png,Pistachio_1.png,Pistachio_2.png,Sunflower_0.png,Sunflower_1.png,Sunflower_2.png",
"name": "plants" "name": "plants"
}, },
{ {
......
...@@ -89,7 +89,7 @@ export const ResJson = { ...@@ -89,7 +89,7 @@ export const ResJson = {
"name": "exchangePanel" "name": "exchangePanel"
}, },
{ {
"keys": "btn_仓库.png,btn_兑换记录.png,btn_商店.png,btn_规则.png,btn_领水滴.png,game_bg.jpg,广告.png,用户_bg.png,用户_头像.png,用户_水.png,田_初始.png,田_种植.png,田_选择.png,种植框_bg.png,种植框_left.png,种植框_right.png,种植框_山核桃.png,种植框_开心果.png,种植框_板栗.png,种植框_瓜子.png,种植框_腰果.png,种植框_花生.png,种植框_袋子.png,进度_bg.png,进度_fill.png", "keys": "btn_仓库.png,btn_兑换记录.png,btn_商店.png,btn_规则.png,btn_领水滴.png,game_bg.jpg,广告.png,用户_bg.png,用户_头像.png,用户_水.png,田_初始.png,田_种植.png,田_选择.png,种植框_bg.png,种植框_left.png,种植框_right.png,种植框_time_bg.png,种植框_山核桃.png,种植框_开心果.png,种植框_板栗.png,种植框_瓜子.png,种植框_腰果.png,种植框_花生.png,袋子.png,进度_bg.png,进度_fill.png",
"name": "gameScene" "name": "gameScene"
}, },
{ {
...@@ -101,7 +101,7 @@ export const ResJson = { ...@@ -101,7 +101,7 @@ export const ResJson = {
"name": "panel" "name": "panel"
}, },
{ {
"keys": "Cashew_0.png,Cashew_1.png,Cashew_2.png,Cashew_seed.png,Chestnut_0.png,Chestnut_1.png,Chestnut_2.png,Chestnut_seed.png,Peanut_0.png,Peanut_1.png,Peanut_2.png,Peanut_seed.png,Pecan_0.png,Pecan_1.png,Pecan_2.png,Pecan_seed.png,Pistachio_0.png,Pistachio_1.png,Pistachio_2.png,Pistachio_seed.png,Sunflower_0.png,Sunflower_1.png,Sunflower_2.png,Sunflower_seed.png", "keys": "Cashew_0.png,Cashew_1.png,Cashew_2.png,Chestnut_0.png,Chestnut_1.png,Chestnut_2.png,Peanut_0.png,Peanut_1.png,Peanut_2.png,Pecan_0.png,Pecan_1.png,Pecan_2.png,Pistachio_0.png,Pistachio_1.png,Pistachio_2.png,Sunflower_0.png,Sunflower_1.png,Sunflower_2.png",
"name": "plants" "name": "plants"
}, },
{ {
......
import IEffect from "../../IEffect"; import IEffect from "../../IEffect";
import { PLANT_TYPE } from "../../../const/staticData"; import { PLANT_TYPE, s_PlantData } from "../../../const/staticData";
import Sprite = FYGE.Sprite;
import Tween = FYGE.Tween; import Tween = FYGE.Tween;
import Event = FYGE.Event; import Event = FYGE.Event;
import Container = FYGE.Container; import Container = FYGE.Container;
...@@ -13,16 +12,17 @@ export default class SeedEffect extends Container implements IEffect { ...@@ -13,16 +12,17 @@ export default class SeedEffect extends Container implements IEffect {
return this._type return this._type
} }
private img: Sprite;
constructor(type: PLANT_TYPE | string) { constructor(type: PLANT_TYPE | string) {
super(); super();
this._type = type; this._type = type;
this.img = this.addChild(Tool.getSprite(`${type}_seed.png`)); this.addChild(Tool.getSprite('袋子.png'));
this.img.position.set(210, 110); const seedImg = this.addChild(Tool.getSprite(`种植框_${s_PlantData[type].name}.png`));
this.img.anchorTexture.set(0.5, 1);
seedImg.position.set((this.width - seedImg.width) / 2 - 5, (this.height - seedImg.height) / 2 + 10);
this.anchor.set(this.width / 2, this.height / 2);
} }
public play(loop: boolean = false) { public play(loop: boolean = false) {
...@@ -33,7 +33,7 @@ export default class SeedEffect extends Container implements IEffect { ...@@ -33,7 +33,7 @@ export default class SeedEffect extends Container implements IEffect {
// 位置:0s(原位) - 0.1s(原位保持不动) - 0.27s(上移10px) - 0.43s(下移10px至原位) // 位置:0s(原位) - 0.1s(原位保持不动) - 0.27s(上移10px) - 0.43s(下移10px至原位)
// -0.8s(原位保持不动) - 0.97s(上移10px) - 1.13s(下移10px至原位) - 1.4s(原位保持不动); // -0.8s(原位保持不动) - 0.97s(上移10px) - 1.13s(下移10px至原位) - 1.4s(原位保持不动);
this.stop(); this.stop();
Tween.get(this.img, {loop: loop}) Tween.get(this, {loop: loop})
.set({scaleX: 1, scaleY: 1}) .set({scaleX: 1, scaleY: 1})
.to({scaleX: 1.1, scaleY: 0.9}, 100) .to({scaleX: 1.1, scaleY: 0.9}, 100)
.to({scaleX: 0.9, scaleY: 1.1}, 170) .to({scaleX: 0.9, scaleY: 1.1}, 170)
...@@ -48,13 +48,13 @@ export default class SeedEffect extends Container implements IEffect { ...@@ -48,13 +48,13 @@ export default class SeedEffect extends Container implements IEffect {
.to({scaleX: 1, scaleY: 1}, 70) .to({scaleX: 1, scaleY: 1}, 70)
.wait(130) .wait(130)
const _y = this.img.y; const _y = this.y;
Tween.get(this.img, {loop: loop}) Tween.get(this, {loop: loop})
.wait(100) .wait(100)
.to({y: _y - 10}, 170) .to({y: _y - 20}, 170)
.to({y: _y}, 160) .to({y: _y}, 160)
.wait(370) .wait(370)
.to({y: _y - 10}, 170) .to({y: _y - 20}, 170)
.to({y: _y}, 160) .to({y: _y}, 160)
.wait(270) .wait(270)
.call(() => { .call(() => {
...@@ -65,11 +65,11 @@ export default class SeedEffect extends Container implements IEffect { ...@@ -65,11 +65,11 @@ export default class SeedEffect extends Container implements IEffect {
public reset() { public reset() {
this.stop(); this.stop();
this.img.scale.set(1, 1); this.scale.set(1, 1);
} }
public stop() { public stop() {
Tween.removeTweens(this.img); Tween.removeTweens(this);
} }
} }
...@@ -41,8 +41,8 @@ export default class GameLayer extends Container { ...@@ -41,8 +41,8 @@ export default class GameLayer extends Container {
state: PLANT_STATE.STATE1, state: PLANT_STATE.STATE1,
}, },
{ {
type: PLANT_TYPE.Cashew, type: PLANT_TYPE.NONE,
state: PLANT_STATE.STATE2, state: 0,
}, },
{ {
type: PLANT_TYPE.Sunflower, type: PLANT_TYPE.Sunflower,
......
...@@ -50,6 +50,7 @@ export default class Plant extends Container { ...@@ -50,6 +50,7 @@ export default class Plant extends Container {
// 播放种子动画 // 播放种子动画
this.addChild(seedEffect); this.addChild(seedEffect);
seedEffect.position.set(155, 30);
seedEffect.play(); seedEffect.play();
seedEffect.once(Event.END_FRAME, () => { seedEffect.once(Event.END_FRAME, () => {
// 移除种子动画 // 移除种子动画
......
...@@ -128,9 +128,12 @@ class ListPlant extends Container implements IScrollListItem { ...@@ -128,9 +128,12 @@ class ListPlant extends Container implements IScrollListItem {
this.width = 108; this.width = 108;
this.height = 160; this.height = 160;
this.addChild(Tool.getSprite('种植框_袋子.png')) this.addChild(Tool.getSprite('袋子.png'))
.position.set(0, 21); .position.set(0, 21);
this.addChild(Tool.getSprite('种植框_time_bg.png'))
.position.set(73, 75);
// 名字的label // 名字的label
this.nameLabel = this.addChild(new TextField()); this.nameLabel = this.addChild(new TextField());
this.nameLabel.position.set(0, 125); this.nameLabel.position.set(0, 125);
......
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