| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import GamePage from "../GamePage";
- const {ccclass, property} = cc._decorator;
- /**长条基类 */
- @ccclass
- export default class BlockLong extends cc.Component {
- @property({type: cc.Animation})
- animation: cc.Animation = null;
- /**是否可见 */
- visiable: boolean = false;
- /**能否被打击 */
- canHit: boolean = false;
- /**初始次数 */
- initCount: number = 0;
- /**剩余可击打次数 */
- count: number = 0;
- /**位置索引 */
- index: number;
- /**播放动画,开始该对象的逻辑 */
- release() {
- this.index = Math.random() * 3 << 0;
- let block_long: BlockLong;
- let animation_name: string;
- if (this.index == 1) {
- block_long = this.node.parent.getChildByName("block_long").getComponent(BlockLong);
- animation_name = "block_long";
- } else {
- block_long = this.node.parent.getChildByName("block_long_side").getComponent(BlockLong);
- animation_name = "block_long_side";
- }
- if (this.index == 0) {
- block_long.node.x = -Math.abs(block_long.node.x);
- block_long.node.scaleX = 1;
- } else if (this.index == 2) {
- block_long.node.x = Math.abs(block_long.node.x);
- block_long.node.scaleX = -1;
- }
-
- GamePage.instance.block_long = block_long;
- block_long.index = this.index;
- block_long.canHit = this.canHit;
- block_long.initCount = this.initCount;
- block_long.count = this.count;
- block_long.visiable = true;
- block_long.animation.play(animation_name);
- }
- /**刚进入击打线触发 */
- reach() {
- this.canHit = true;
- }
- /**完全离开击打线触发 */
- leave() {
- if (this.initCount == this.count) {
- GamePage.instance.miss();
- }
- GamePage.instance.countOverBeat(this.initCount);
- this.visiable = false;
- this.canHit = false;
- }
- }
|