[Add]: Enemies Waves

This commit is contained in:
Mohammad_Hasan 2025-10-28 16:32:18 +04:00
parent 7d271a8f25
commit 3576a2e2a0
9 changed files with 2042 additions and 76 deletions

1696
assets/Level.fire Normal file

File diff suppressed because it is too large Load Diff

7
assets/Level.fire.meta Normal file
View File

@ -0,0 +1,7 @@
{
"ver": "1.2.1",
"uuid": "3eba991d-703c-4c11-ac81-b6548a4722ec",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}

View File

@ -69,10 +69,10 @@
"_level": 1, "_level": 1,
"_components": [ "_components": [
{ {
"__id__": 8 "__id__": 14
}, },
{ {
"__id__": 9 "__id__": 15
} }
], ],
"_prefab": null, "_prefab": null,
@ -156,7 +156,7 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": 876.417708629852 "z": 780.2888888097792
}, },
"_scale": { "_scale": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -213,20 +213,24 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "play", "_name": "button",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
}, },
"_children": [], "_children": [
{
"__id__": 6
}
],
"_active": true, "_active": true,
"_level": 2, "_level": 2,
"_components": [ "_components": [
{ {
"__id__": 6 "__id__": 11
}, },
{ {
"__id__": 7 "__id__": 13
} }
], ],
"_prefab": null, "_prefab": null,
@ -241,7 +245,7 @@
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 416, "width": 416,
"height": 108 "height": 148
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@ -257,7 +261,7 @@
"_scale": { "_scale": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 1, "x": 1,
"y": 0.66, "y": 0.44445,
"z": 1 "z": 1
}, },
"_eulerAngles": { "_eulerAngles": {
@ -270,14 +274,169 @@
"_skewY": 0, "_skewY": 0,
"_is3DNode": false, "_is3DNode": false,
"groupIndex": 0, "groupIndex": 0,
"_id": "9c/kR6zopOCq2Elgf3X+l+" "_id": "69HYmEC4hC1aoSBRgg0FAJ"
},
{
"__type__": "cc.Node",
"_name": "Background",
"_objFlags": 0,
"_parent": {
"__id__": 5
},
"_children": [
{
"__id__": 7
}
],
"_active": true,
"_level": 2,
"_components": [
{
"__id__": 9
},
{
"__id__": 10
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 26,
"g": 26,
"b": 26,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 416,
"height": 148
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"groupIndex": 0,
"_id": "a3huG/zeRBTLCQROSq3ztB"
},
{
"__type__": "cc.Node",
"_name": "Label",
"_objFlags": 0,
"_parent": {
"__id__": 6
},
"_children": [],
"_active": true,
"_level": 3,
"_components": [
{
"__id__": 8
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 200,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"groupIndex": 0,
"_id": "f7ZK1FmCpCZ5ivVxgV+zW0"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_useOriginalSize": false,
"_string": "START",
"_N$string": "START",
"_fontSize": 50,
"_lineHeight": 40,
"_enableWrapText": false,
"_N$file": null,
"_isSystemFontUsed": true,
"_isUseVerticalKerning": true,
"_verticalKerning": null,
"_spacingX": 0,
"_batchAsBitmap": false,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 1,
"_N$cacheMode": 0,
"_id": "e35+dINdxC/49nsWhSHhH3"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 5 "__id__": 6
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
@ -288,10 +447,10 @@
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "983fa58a-66aa-4526-a54d-dc95037f1259" "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
}, },
"_type": 0, "_type": 1,
"_sizeMode": 1, "_sizeMode": 0,
"_fillType": 0, "_fillType": 0,
"_fillCenter": { "_fillCenter": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@ -302,7 +461,128 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "3bA5w73CpHDrHFTBeG9DGv" "_id": "6d7ZTBMFxAvrmL5zbdC4vz"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_enabled": true,
"alignMode": 0,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 100,
"_originalHeight": 40,
"_id": "65HbE6twJMupjXdRg8qNia"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [
{
"__id__": 12
}
],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 2,
"transition": 2,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 230,
"g": 230,
"b": 230,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 200,
"g": 200,
"b": 200,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 200,
"g": 200,
"b": 200,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 120,
"g": 120,
"b": 120,
"a": 200
},
"_N$normalSprite": {
"__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
},
"_N$pressedSprite": {
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
},
"pressedSprite": {
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
},
"_N$hoverSprite": {
"__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
},
"hoverSprite": {
"__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
},
"_N$disabledSprite": {
"__uuid__": "29158224-f8dd-4661-a796-1ffab537140e"
},
"_N$target": {
"__id__": 6
},
"_id": "04Dqh37IRDyLnnoepjmU10"
},
{
"__type__": "cc.ClickEvent",
"target": {
"__id__": 5
},
"component": "",
"_componentId": "3a2abJhRaJFyrM9SBg5rWtB",
"handler": "loadLevelsScene",
"customEventData": ""
}, },
{ {
"__type__": "3a2abJhRaJFyrM9SBg5rWtB", "__type__": "3a2abJhRaJFyrM9SBg5rWtB",
@ -312,9 +592,7 @@
"__id__": 5 "__id__": 5
}, },
"_enabled": true, "_enabled": true,
"label": null, "_id": "b1l7jFcrZGValOGBcgRpBB"
"text": "hello",
"_id": "c9ABQ2655OSa44WE6gYPfI"
}, },
{ {
"__type__": "cc.Canvas", "__type__": "cc.Canvas",

View File

@ -13,8 +13,9 @@ const {ccclass, property} = cc._decorator;
@ccclass @ccclass
export default class NewClass extends cc.Component { export default class NewClass extends cc.Component {
duratrion : number = 15; duratrion : number = 2.5;
moveAmountY : number = 25; moveAmountX : number = 0;
RTL: boolean = false;
moveEnemy : cc.ActionInterval; moveEnemy : cc.ActionInterval;
@ -26,8 +27,9 @@ export default class NewClass extends cc.Component {
playAnimation : Boolean = true; playAnimation : Boolean = true;
setMovements() { setMovements() {
var moveDown = cc.moveBy(this.duratrion, cc.v2(0, -this.node.parent.getContentSize().height * 0.95)); var moveLeft = cc.moveBy(this.duratrion, cc.v2(-this.moveAmountX, -this.node.parent.getContentSize().height * 0.32));
this.node.runAction(cc.repeatForever(moveDown)); var moveRight = cc.moveBy(this.duratrion, cc.v2(this.moveAmountX, -this.node.parent.getContentSize().height * 0.32));
this.node.runAction(cc.repeatForever(this.RTL ? cc.sequence(moveRight, moveLeft) : cc.sequence(moveLeft, moveRight)));
} }
shootBullets() { shootBullets() {

View File

@ -24,11 +24,32 @@ export default class NewClass extends cc.Component {
spawnShips() { spawnShips() {
var ships = [this.alienship1, this.alienship2, this.alienship3]; var ships = [this.alienship1, this.alienship2, this.alienship3];
var ship = cc.instantiate(ships[Math.floor(Math.random() * ships.length)]); var randomShip = Math.floor(Math.random() * ships.length);
const shipX = Math.random() * 800 - 400; var RTL = Math.random() < 0.5;
var shipPrefab = ships[randomShip];
const batchMoveAmountX = Math.random() * 200 + 200;
const shipY = this.node.getContentSize().height * 0.95; const shipY = this.node.getContentSize().height * 0.95;
ship.setPosition(shipX, shipY);
this.node.addChild(ship); const screenHalfWidth = this.node.getContentSize().width / 2;
const shipMaxMove = batchMoveAmountX;
const margin = 0;
const shipXMin = -screenHalfWidth + shipMaxMove + margin;
const shipXMax = screenHalfWidth - shipMaxMove - margin;
const shipX = Math.random() * (shipXMax - shipXMin) + shipXMin;
for (let i = 0; i < 12; i++) {
this.scheduleOnce(() => {
const ship = cc.instantiate(shipPrefab);
ship.setPosition(shipX, shipY);
this.node.addChild(ship);
const shipScript = ship.getComponent('EnemyShip');
shipScript.moveAmountX = batchMoveAmountX;
shipScript.RTL = RTL;
}, i * 0.5);
}
} }
onLoad () { onLoad () {
@ -37,8 +58,8 @@ export default class NewClass extends cc.Component {
} }
start () { start () {
this.schedule(this.spawnShips, 1, cc.macro.REPEAT_FOREVER, 1); this.schedule(this.spawnShips, 5, cc.macro.REPEAT_FOREVER, 1);
} }
// update (dt) {} // update (dt) {}
} }

View File

@ -30,6 +30,7 @@ export default class NewClass extends cc.Component {
const protonX = Math.random() * this.node.getContentSize().width - this.node.getContentSize().width / 2; const protonX = Math.random() * this.node.getContentSize().width - this.node.getContentSize().width / 2;
const protonY = this.node.getContentSize().height; const protonY = this.node.getContentSize().height;
proton.setPosition(protonX, protonY); proton.setPosition(protonX, protonY);
proton.zIndex = -1;
this.node.addChild(proton); this.node.addChild(proton);
} }

View File

@ -13,20 +13,15 @@ const {ccclass, property} = cc._decorator;
@ccclass @ccclass
export default class NewClass extends cc.Component { export default class NewClass extends cc.Component {
@property(cc.Label) loadLevelsScene() {
label: cc.Label = null; cc.director.preloadScene('Level', () => {
cc.director.loadScene('Level');
});
}
@property loadGameScene(event, customData) {
text: string = 'hello'; cc.director.preloadScene('Level', () => {
cc.director.loadScene('Level');
// LIFE-CYCLE CALLBACKS: });
// onLoad () {}
start () {
cc.director.preloadScene('Game');
this.node.on('touchstart', () => {
cc.director.loadScene('Game');
}, this);
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -1,34 +0,0 @@
{
"ver": "2.3.3",
"uuid": "2ca4193f-b750-49e3-afdd-d62a6855f675",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"platformSettings": {},
"subMetas": {
"play": {
"ver": "1.0.4",
"uuid": "983fa58a-66aa-4526-a54d-dc95037f1259",
"rawTextureUuid": "2ca4193f-b750-49e3-afdd-d62a6855f675",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 416,
"height": 108,
"rawWidth": 416,
"rawHeight": 108,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}