store-v2 #1
@ -162,7 +162,7 @@
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 876.417708629852
|
||||
"z": 539.5338265577053
|
||||
},
|
||||
"_scale": {
|
||||
"__type__": "cc.Vec3",
|
||||
|
||||
@ -13,8 +13,7 @@ const {ccclass, property} = cc._decorator;
|
||||
@ccclass
|
||||
export default class NewClass extends cc.Component {
|
||||
|
||||
duratrion : number = 0.5;
|
||||
moveAmountX : number = 50;
|
||||
duratrion : number = 15;
|
||||
moveAmountY : number = 25;
|
||||
|
||||
moveEnemy : cc.ActionInterval;
|
||||
@ -27,9 +26,8 @@ export default class NewClass extends cc.Component {
|
||||
playAnimation : Boolean = true;
|
||||
|
||||
setMovements() {
|
||||
var moveLeft = cc.moveBy(this.duratrion, cc.v2(-this.moveAmountX, -this.moveAmountY)).easing(cc.easeCircleActionInOut());
|
||||
var moveRight = cc.moveBy(this.duratrion, cc.v2(this.moveAmountX, -this.moveAmountY)).easing(cc.easeCircleActionInOut());
|
||||
return cc.repeatForever(cc.sequence(moveLeft, moveRight));
|
||||
var moveDown = cc.moveBy(this.duratrion, cc.v2(0, -this.node.parent.getContentSize().height * 0.95));
|
||||
this.node.runAction(cc.repeatForever(moveDown));
|
||||
}
|
||||
|
||||
shootBullets() {
|
||||
@ -41,8 +39,7 @@ export default class NewClass extends cc.Component {
|
||||
// LIFE-CYCLE CALLBACKS:
|
||||
|
||||
onLoad () {
|
||||
this.moveEnemy = this.setMovements();
|
||||
this.node.runAction(this.moveEnemy);
|
||||
this.scheduleOnce(this.setMovements, 0.1);
|
||||
|
||||
this.schedule(this.shootBullets, Math.random() * 1 + 1, cc.macro.REPEAT_FOREVER, 0);
|
||||
}
|
||||
@ -50,6 +47,7 @@ export default class NewClass extends cc.Component {
|
||||
if(otherCollider.name === 'greenbullet<PolygonCollider>') {
|
||||
this.enemyLife--;
|
||||
if(this.enemyLife <= 0 && this.playAnimation) {
|
||||
this.node.getComponent(cc.Collider).enabled = false;
|
||||
this.node.stopAllActions();
|
||||
this.playAnimation = false;
|
||||
this.node.getComponent(cc.Animation).play();
|
||||
|
||||
@ -30,7 +30,7 @@ export default class NewClass extends cc.Component {
|
||||
update (dt) {
|
||||
this.node.setPosition(
|
||||
this.node.parent.getChildByName('player').position.x,
|
||||
this.node.parent.getChildByName('player').position.y - 30
|
||||
this.node.parent.getChildByName('player').position.y - 50
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user