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