Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Plane_Fight
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
Plane_Fight
Commits
a090e283
Commit
a090e283
authored
Feb 20, 2022
by
智慧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:子弹碰撞敌人,销毁敌人并且销毁自己
parent
33d31985
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
607 additions
and
1 deletion
+607
-1
bulletControl.ts
assets/cocos_generator/scene/bulletControl.ts
+33
-0
bulletControl.ts.meta
assets/cocos_generator/scene/bulletControl.ts.meta
+9
-0
cocos_generator.fire
assets/cocos_generator/scene/cocos_generator.fire
+285
-0
enemyControl.ts
assets/cocos_generator/scene/enemyControl.ts
+17
-0
enemyControl.ts.meta
assets/cocos_generator/scene/enemyControl.ts.meta
+9
-0
playerControl.ts
assets/cocos_generator/scene/playerControl.ts
+18
-1
bullet1.png
assets/cocos_generator/textures/bullet1.png
+0
-0
bullet1.png.meta
assets/cocos_generator/textures/bullet1.png.meta
+36
-0
bullet1.prefab
assets/cocos_generator/textures/bullet1.prefab
+156
-0
bullet1.prefab.meta
assets/cocos_generator/textures/bullet1.prefab.meta
+8
-0
enemy1.png
assets/cocos_generator/textures/enemy1.png
+0
-0
enemy1.png.meta
assets/cocos_generator/textures/enemy1.png.meta
+36
-0
No files found.
assets/cocos_generator/scene/bulletControl.ts
0 → 100644
View file @
a090e283
import
EnemyControl
from
"
./enemyControl
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
BulletControl
extends
cc
.
Component
{
@
property
speed
:
number
=
648
;
start
()
{
}
update
(
dt
)
{
// 移动
this
.
node
.
y
+=
this
.
speed
*
dt
;
// 出屏幕销毁
if
(
this
.
node
.
y
>
660
)
{
this
.
node
.
destroy
();
}
}
onCollisionEnter
(
other
)
{
//如果碰到敌人,销毁自己让自己死亡
if
(
other
.
tag
==
1
)
{
//销毁敌人
other
.
getComponent
(
EnemyControl
).
die
();
//销毁自己
this
.
node
.
destroy
();
}
}
}
assets/cocos_generator/scene/bulletControl.ts.meta
0 → 100644
View file @
a090e283
{
"ver": "1.0.8",
"uuid": "156fd4d1-30e5-4c4f-9d40-c1ba4f151d91",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
assets/cocos_generator/scene/cocos_generator.fire
View file @
a090e283
...
...
@@ -21,6 +21,12 @@
},
{
"__id__": 12
},
{
"__id__": 15
},
{
"__id__": 20
}
],
"_active": false,
...
...
@@ -619,6 +625,285 @@
"__id__": 12
},
"_enabled": true,
"bulletPre": {
"__uuid__": "a196535c-ed2e-49d6-a7d9-de56a41c1fbb"
},
"_id": "7cp3iohZBBer32Lh+4Acro"
},
{
"__type__": "cc.Node",
"_name": "bullet1",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 16
},
{
"__id__": 17
},
{
"__id__": 18
}
],
"_prefab": {
"__id__": 19
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 5,
"height": 11
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
239.329,
163.178,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "23i/SUn/RFg7G8z62wgd2I"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "4137bde6-07d6-4e31-80e5-760d55460f1b"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "07+EJLpNZDJrau6Gqnj2mY"
},
{
"__type__": "cc.BoxCollider",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
},
"_enabled": true,
"tag": 0,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_size": {
"__type__": "cc.Size",
"width": 5,
"height": 11
},
"_id": "c3ZeNVy+tGi5t+1KHC7Hxz"
},
{
"__type__": "156fdTRMOVMT51AwbpPFR2R",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
},
"_enabled": true,
"speed": 800,
"_id": "95uRQ23ptKyIEmjR5CiEWv"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 15
},
"asset": {
"__uuid__": "a196535c-ed2e-49d6-a7d9-de56a41c1fbb"
},
"fileId": "",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "enemy",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 21
},
{
"__id__": 22
},
{
"__id__": 23
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 51,
"height": 38
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
154.476,
509.117,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "5cdVHfYv9H8IDA7WFeGcrZ"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 20
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "5c693fcc-43f6-4f16-b3b7-55672662654a"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "572uE6ztZLIYUz2tX5toAL"
},
{
"__type__": "cc.BoxCollider",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 20
},
"_enabled": true,
"tag": 1,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 1.9
},
"_size": {
"__type__": "cc.Size",
"width": 43.4,
"height": 32.3
},
"_id": "240JwdjLVGvLFBHWtOcYww"
},
{
"__type__": "e4cffTABZpCL58N/un/x4eE",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 20
},
"_enabled": true,
"_id": "4aLf5u87xPfJogtnzuJXnP"
}
]
\ No newline at end of file
assets/cocos_generator/scene/enemyControl.ts
0 → 100644
View file @
a090e283
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
EnemyControl
extends
cc
.
Component
{
start
()
{
}
update
(
dt
)
{}
//死亡
die
()
{
this
.
node
.
destroy
();
}
}
assets/cocos_generator/scene/enemyControl.ts.meta
0 → 100644
View file @
a090e283
{
"ver": "1.0.8",
"uuid": "e4cff4c0-059a-422f-9f0d-fee9ffc78784",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
assets/cocos_generator/scene/playerControl.ts
View file @
a090e283
...
...
@@ -2,13 +2,30 @@
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
NewClass
extends
cc
.
Component
{
export
default
class
PlayerControl
extends
cc
.
Component
{
@
property
(
cc
.
Prefab
)
bulletPre
:
cc
.
Prefab
=
null
;
start
()
{
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
(
event
)
=>
{
this
.
node
.
setPosition
(
event
.
getLocation
());
});
//攻击 计时器
this
.
schedule
(()
=>
{
//创建子弹 需要预设体
let
bullet
=
cc
.
instantiate
(
this
.
bulletPre
);
//设置父物体
bullet
.
setParent
(
cc
.
director
.
getScene
());
//设置子弹的坐标
bullet
.
x
=
this
.
node
.
x
;
bullet
.
y
=
this
.
node
.
y
+
60
;
},
0.5
);
//开启碰撞
cc
.
director
.
getCollisionManager
().
enabled
=
true
;
}
// update (dt) {}
}
assets/cocos_generator/textures/bullet1.png
0 → 100644
View file @
a090e283
292 Bytes
assets/cocos_generator/textures/bullet1.png.meta
0 → 100644
View file @
a090e283
{
"ver": "2.3.5",
"uuid": "001710c1-f849-4d01-b6be-d939df7c7534",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 5,
"height": 11,
"platformSettings": {},
"subMetas": {
"bullet1": {
"ver": "1.0.4",
"uuid": "4137bde6-07d6-4e31-80e5-760d55460f1b",
"rawTextureUuid": "001710c1-f849-4d01-b6be-d939df7c7534",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 5,
"height": 11,
"rawWidth": 5,
"rawHeight": 11,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
assets/cocos_generator/textures/bullet1.prefab
0 → 100644
View file @
a090e283
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "bullet1",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 3
},
{
"__id__": 4
}
],
"_prefab": {
"__id__": 5
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 5,
"height": 11
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
239.329,
163.178,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "4137bde6-07d6-4e31-80e5-760d55460f1b"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.BoxCollider",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"tag": 0,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_size": {
"__type__": "cc.Size",
"width": 5,
"height": 11
},
"_id": ""
},
{
"__type__": "156fdTRMOVMT51AwbpPFR2R",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
assets/cocos_generator/textures/bullet1.prefab.meta
0 → 100644
View file @
a090e283
{
"ver": "1.2.9",
"uuid": "a196535c-ed2e-49d6-a7d9-de56a41c1fbb",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
assets/cocos_generator/textures/enemy1.png
0 → 100644
View file @
a090e283
3.16 KB
assets/cocos_generator/textures/enemy1.png.meta
0 → 100644
View file @
a090e283
{
"ver": "2.3.5",
"uuid": "3ca14dfd-28f8-4b8a-9496-c7fc74de1ecc",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 57,
"height": 43,
"platformSettings": {},
"subMetas": {
"enemy1": {
"ver": "1.0.4",
"uuid": "5c693fcc-43f6-4f16-b3b7-55672662654a",
"rawTextureUuid": "3ca14dfd-28f8-4b8a-9496-c7fc74de1ecc",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -1.5,
"trimX": 3,
"trimY": 4,
"width": 51,
"height": 38,
"rawWidth": 57,
"rawHeight": 43,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment