Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
playground
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
wildfirecode13
playground
Commits
454cb6a3
Commit
454cb6a3
authored
Feb 15, 2021
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a53839cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
25 deletions
+34
-25
main.js
test/src/game/main.js
+21
-24
meta.json
test/src/meta.json
+13
-1
No files found.
test/src/game/main.js
View file @
454cb6a3
...
@@ -14,28 +14,26 @@ class GameStage extends WidgetBase {
...
@@ -14,28 +14,26 @@ class GameStage extends WidgetBase {
}
}
addbodys
()
{
addbodys
()
{
const
ball1
=
new
Body
({
const
enemy
=
new
Body
({
display
:
'box'
,
display
:
'enemy'
,
initialVelocityX
:
2
,
initialVelocityY
:
1
initialVelocityY
:
2
});
});
const
ball2
=
new
Body
({
const
bullet
=
new
Body
({
display
:
'box'
,
display
:
'bullet'
,
initialVelocityX
:
-
2
,
initialVelocityY
:
-
4
initialVelocityY
:
-
2
});
});
ball1
.
x
=
0
;
enemy
.
x
=
15
0
;
ball1
.
y
=
0
;
enemy
.
y
=
0
;
b
all2
.
x
=
60
0
;
b
ullet
.
x
=
17
0
;
b
all2
.
y
=
600
;
b
ullet
.
y
=
600
;
this
.
addChild
(
ball1
);
this
.
addChild
(
enemy
);
this
.
bodys
.
push
(
ball1
);
this
.
bodys
.
push
(
enemy
);
this
.
addChild
(
b
all2
);
this
.
addChild
(
b
ullet
);
this
.
bodys
.
push
(
b
all2
);
this
.
bodys
.
push
(
b
ullet
);
}
}
onEnterFrame
()
{
onEnterFrame
()
{
...
@@ -47,14 +45,13 @@ class GameStage extends WidgetBase {
...
@@ -47,14 +45,13 @@ class GameStage extends WidgetBase {
}
}
checkCollide
(
A
,
B
)
{
checkCollide
(
A
,
B
)
{
const
d
=
A
.
width
;
const
pointA
=
[
A
.
x
+
A
.
width
/
2
,
A
.
y
+
A
.
height
/
2
];
const
r
=
d
/
2
;
const
pointB
=
[
B
.
x
+
B
.
width
/
2
,
B
.
y
+
B
.
height
/
2
];
const
pointA
=
[
A
.
x
+
r
,
A
.
y
+
r
];
const
x0
=
Math
.
abs
(
pointA
[
0
]
-
pointB
[
0
]);
const
pointB
=
[
B
.
x
+
r
,
B
.
y
+
r
];
const
y0
=
Math
.
abs
(
pointA
[
1
]
-
pointB
[
1
]);
const
distanceX
=
Math
.
abs
(
pointA
[
0
]
-
pointB
[
0
]);
const
x1
=
A
.
width
/
2
+
B
.
width
/
2
;
const
distanceY
=
Math
.
abs
(
pointA
[
1
]
-
pointB
[
1
]);
const
y1
=
A
.
height
/
2
+
B
.
height
/
2
;
const
distanceAB
=
Math
.
sqrt
(
distanceX
*
distanceX
+
distanceY
*
distanceY
);
return
x0
<
x1
&&
y0
<
y1
;
return
distanceAB
<
d
;
}
}
stopGame
()
{
stopGame
()
{
...
...
test/src/meta.json
View file @
454cb6a3
...
@@ -9,6 +9,18 @@
...
@@ -9,6 +9,18 @@
]
]
},
},
"assets"
:
[
"assets"
:
[
{
"name"
:
"enemy"
,
"ext"
:
".png"
,
"url"
:
"//yun.duiba.com.cn/spark/assets/enemy1_fly1.1cded0d917c44d22ddce058f239e1cfac1b506c2.png"
,
"uuid"
:
"enemy"
},
{
"name"
:
"bullet"
,
"ext"
:
".png"
,
"url"
:
"//yun.duiba.com.cn/spark/assets/bullet1.63bb85f32cabe5f986366c2d428c5e2aa2435230.png"
,
"uuid"
:
"bullet"
},
{
{
"name"
:
"齿轮"
,
"name"
:
"齿轮"
,
"url"
:
"//yun.duiba.com.cn/spark/assets/齿轮8.fce30eaadda192b44a1b80038011947830d45ad8.png"
,
"url"
:
"//yun.duiba.com.cn/spark/assets/齿轮8.fce30eaadda192b44a1b80038011947830d45ad8.png"
,
...
@@ -53,4 +65,4 @@
...
@@ -53,4 +65,4 @@
}
}
}
}
}
}
}
}
\ 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