Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
db-game-template
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
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
崔立强
db-game-template
Commits
52ef2046
Commit
52ef2046
authored
Sep 24, 2018
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
5eca0d6b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
9 deletions
+7
-9
Ball.ts
egret/src/Ball.ts
+5
-8
Gun.ts
egret/src/Gun.ts
+1
-0
Main.ts
egret/src/Main.ts
+1
-1
No files found.
egret/src/Ball.ts
View file @
52ef2046
import
{
addImage
}
from
"./utils"
;
import
{
addImage
}
from
"./utils"
;
import
{
FACTOR
}
from
"./consts"
;
export
default
class
Ball
extends
p2
.
Body
{
export
default
class
Ball
extends
p2
.
Body
{
_skin
:
egret
.
DisplayObject
;
_skin
:
egret
.
DisplayObject
;
constructor
(
options
?:
any
)
{
super
(
options
);
this
.
init
();
}
private
init
()
{
init
()
{
this
.
_skin
=
addImage
(
'ball_png'
);
this
.
_skin
=
addImage
(
'ball_png'
);
this
.
_skin
.
anchorOffsetX
=
this
.
_skin
.
width
/
2
;
this
.
_skin
.
anchorOffsetX
=
this
.
_skin
.
width
/
2
;
this
.
_skin
.
anchorOffsetY
=
this
.
_skin
.
height
/
2
;
this
.
_skin
.
anchorOffsetY
=
this
.
_skin
.
height
/
2
;
const
radius
=
this
.
_skin
.
width
/
2
;
const
radius
=
this
.
_skin
.
width
/
2
/
FACTOR
;
const
shape
=
new
p2
.
Circle
({
radius
:
radius
});
const
shape
=
new
p2
.
Circle
({
radius
:
radius
});
this
.
addShape
(
shape
);
this
.
addShape
(
shape
);
...
@@ -20,8 +17,8 @@ export default class Ball extends p2.Body {
...
@@ -20,8 +17,8 @@ export default class Ball extends p2.Body {
}
}
updateSkin
()
{
updateSkin
()
{
this
.
_skin
.
x
=
this
.
position
[
0
];
this
.
_skin
.
x
=
this
.
position
[
0
]
*
FACTOR
;
this
.
_skin
.
y
=
this
.
position
[
1
];
this
.
_skin
.
y
=
this
.
position
[
1
]
*
FACTOR
;
this
.
_skin
.
rotation
=
this
.
angle
*
180
/
Math
.
PI
;
this
.
_skin
.
rotation
=
this
.
angle
*
180
/
Math
.
PI
;
}
}
...
...
egret/src/Gun.ts
View file @
52ef2046
...
@@ -23,6 +23,7 @@ export default class Gun extends egret.Sprite {
...
@@ -23,6 +23,7 @@ export default class Gun extends egret.Sprite {
addBall
()
{
addBall
()
{
const
ball
=
new
Ball
();
const
ball
=
new
Ball
();
ball
.
init
();
this
.
_world
.
addBody
(
ball
);
this
.
_world
.
addBody
(
ball
);
this
.
_root
.
addChild
(
ball
.
skin
);
this
.
_root
.
addChild
(
ball
.
skin
);
}
}
...
...
egret/src/Main.ts
View file @
52ef2046
...
@@ -29,7 +29,7 @@ export class Main extends eui.UILayer {
...
@@ -29,7 +29,7 @@ export class Main extends eui.UILayer {
}
}
loop
()
{
loop
()
{
this
.
_world
.
step
(
1
/
60
);
this
.
_world
.
step
(
1
);
this
.
_world
.
loop
();
this
.
_world
.
loop
();
}
}
...
...
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