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
335b1357
Commit
335b1357
authored
Sep 29, 2018
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
973419b0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
6 deletions
+84
-6
.buildrc.js
.buildrc.js
+15
-1
Gun.ts
egret/src/Gun.ts
+7
-2
Main.ts
egret/src/Main.ts
+23
-3
Wall.ts
egret/src/Wall.ts
+39
-0
No files found.
.buildrc.js
View file @
335b1357
module
.
exports
=
{
module
.
exports
=
{
devPort
:
8080
devPort
:
8080
,
proxy
:
{
'/ngapi/*'
:
'http://localhost:3000'
,
'/plugin/*'
:
'http://localhost:3000'
,
'/ngame/*'
:
'http://localhost:3000'
,
'/activityCommon/*'
:
'http://localhost:3000'
,
'/ctool/*'
:
'http://localhost:3000'
,
'/activityVist/*'
:
'http://localhost:3000'
,
'/collectGoods/*'
:
'http://localhost:3000'
,
'/activityPlugDrawInfo/*'
:
'http://localhost:3000'
,
'/collectRule/*'
:
'http://localhost:3000'
,
'/hdtool/*'
:
'http://localhost:3000'
,
'/activityPlugin/*'
:
'http://localhost:3000'
,
'/summer/*'
:
'http://localhost:3000'
}
}
}
// const path = require('path');
// const path = require('path');
...
...
egret/src/Gun.ts
View file @
335b1357
...
@@ -3,6 +3,7 @@ import Ball from "./Ball";
...
@@ -3,6 +3,7 @@ import Ball from "./Ball";
import
World
from
"./World"
;
import
World
from
"./World"
;
import
{
FACTOR
}
from
"./consts"
;
import
{
FACTOR
}
from
"./consts"
;
import
Brick
from
"./Brick"
;
import
Brick
from
"./Brick"
;
import
Wall
from
"./Wall"
;
export
default
class
Gun
extends
egret
.
Sprite
{
export
default
class
Gun
extends
egret
.
Sprite
{
_root
:
egret
.
DisplayObjectContainer
;
_root
:
egret
.
DisplayObjectContainer
;
...
@@ -24,7 +25,7 @@ export default class Gun extends egret.Sprite {
...
@@ -24,7 +25,7 @@ export default class Gun extends egret.Sprite {
const
ball
=
this
.
addBall
();
const
ball
=
this
.
addBall
();
ball
.
mass
=
0
;
ball
.
mass
=
0
;
this
.
_world
.
bodies
.
forEach
(
body
=>
{
this
.
_world
.
bodies
.
forEach
(
body
=>
{
if
(
body
instanceof
Brick
)
{
if
(
body
instanceof
Brick
||
body
instanceof
Wall
)
{
this
.
_world
.
setMaterial
(
ball
,
body
);
this
.
_world
.
setMaterial
(
ball
,
body
);
}
}
})
})
...
@@ -53,6 +54,9 @@ export default class Gun extends egret.Sprite {
...
@@ -53,6 +54,9 @@ export default class Gun extends egret.Sprite {
}
}
onTouchEnd
(
e
:
egret
.
TouchEvent
):
any
{
onTouchEnd
(
e
:
egret
.
TouchEvent
):
any
{
setTimeout
(()
=>
{
this
.
enable
();
},
500
);
this
.
hideLine
();
this
.
hideLine
();
this
.
stage
.
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_MOVE
,
this
.
onTouchMove
,
this
);
this
.
stage
.
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_MOVE
,
this
.
onTouchMove
,
this
);
...
@@ -92,6 +96,7 @@ export default class Gun extends egret.Sprite {
...
@@ -92,6 +96,7 @@ export default class Gun extends egret.Sprite {
}
}
hideLine
()
{
hideLine
()
{
if
(
this
.
_line
.
parent
)
this
.
removeChild
(
this
.
_line
)
this
.
removeChild
(
this
.
_line
)
}
}
}
}
\ No newline at end of file
egret/src/Main.ts
View file @
335b1357
...
@@ -3,6 +3,7 @@ import Gun from "./Gun";
...
@@ -3,6 +3,7 @@ import Gun from "./Gun";
import
World
from
"./World"
;
import
World
from
"./World"
;
import
Brick
from
"./Brick"
;
import
Brick
from
"./Brick"
;
import
{
FACTOR
}
from
"./consts"
;
import
{
FACTOR
}
from
"./consts"
;
import
Wall
from
"./Wall"
;
export
class
Main
extends
eui
.
UILayer
{
export
class
Main
extends
eui
.
UILayer
{
private
_gun
:
Gun
;
private
_gun
:
Gun
;
...
@@ -20,6 +21,7 @@ export class Main extends eui.UILayer {
...
@@ -20,6 +21,7 @@ export class Main extends eui.UILayer {
this
.
_gun
.
y
=
100
;
this
.
_gun
.
y
=
100
;
this
.
_gun
.
enable
();
this
.
_gun
.
enable
();
this
.
createGround
();
this
.
updateBrickBody
();
this
.
updateBrickBody
();
...
@@ -27,11 +29,29 @@ export class Main extends eui.UILayer {
...
@@ -27,11 +29,29 @@ export class Main extends eui.UILayer {
this
.
addEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
loop
,
this
);
this
.
addEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
loop
,
this
);
}
}
createGround
()
{
const
left
=
new
Wall
(
true
);
const
right
=
new
Wall
(
false
);
this
.
_world
.
addBody
(
left
);
this
.
_world
.
addBody
(
right
);
this
.
_world
.
skin
.
addChild
(
left
.
skin
);
this
.
_world
.
skin
.
addChild
(
right
.
skin
);
left
.
position
=
[
left
.
skin
.
width
/
2
,
left
.
skin
.
height
/
2
];
right
.
position
=
[
this
.
stage
.
stageWidth
-
right
.
skin
.
width
/
2
,
right
.
skin
.
height
/
2
];
this
.
_world
.
addBody
(
left
);
this
.
_world
.
addBody
(
right
);
right
.
updateSkin
();
left
.
updateSkin
();
}
updateBrickBody
():
void
{
updateBrickBody
():
void
{
for
(
var
i
=
0
;
i
<
1
;
i
++
)
{
const
xlist
=
[
150
,
300
,
450
,
600
];
for
(
var
i
=
0
;
i
<
xlist
.
length
;
i
++
)
{
var
brick
=
new
Brick
();
var
brick
=
new
Brick
();
var
x
=
this
.
stage
.
stageWidth
>>
1
;
// var x = 100 this.stage.stageWidth - 100 ;
var
y
=
1000
;
var
x
=
xlist
[
i
];
var
y
=
Math
.
random
()
*
100
+
800
;
brick
.
position
=
[
x
/
FACTOR
,
y
/
FACTOR
];
brick
.
position
=
[
x
/
FACTOR
,
y
/
FACTOR
];
brick
.
updateSkin
();
brick
.
updateSkin
();
brick
.
angle
=
(
-
Math
.
random
()
*
Math
.
PI
/
4
)
+
(
Math
.
random
()
*
Math
.
PI
/
4
);
brick
.
angle
=
(
-
Math
.
random
()
*
Math
.
PI
/
4
)
+
(
Math
.
random
()
*
Math
.
PI
/
4
);
...
...
egret/src/Wall.ts
0 → 100644
View file @
335b1357
import
{
addImage
}
from
"./utils"
;
import
{
FACTOR
}
from
"./consts"
;
/**
* 被打的砖块
*/
export
default
class
Wall
extends
p2
.
Body
{
_skin
:
egret
.
DisplayObject
;
_isLeft
:
boolean
;
leftOrRight
()
{
return
this
.
_isLeft
}
constructor
(
isLeft
)
{
super
();
this
.
_isLeft
=
isLeft
;
this
.
type
=
p2
.
Body
.
KINEMATIC
;
this
.
init
();
}
init
()
{
const
skinName
=
this
.
_isLeft
?
'left_png'
:
'right_png'
;
this
.
_skin
=
addImage
(
skinName
);
this
.
_skin
.
anchorOffsetX
=
this
.
_skin
.
width
/
2
;
this
.
_skin
.
anchorOffsetY
=
this
.
_skin
.
height
/
2
;
const
width
=
this
.
_skin
.
width
/
FACTOR
;
const
height
=
this
.
_skin
.
height
/
FACTOR
;
const
shape
=
new
p2
.
Box
({
width
:
width
,
height
:
height
});
this
.
addShape
(
shape
);
shape
.
collisionMask
=
6
;
//010与001为0,010与110为1
}
updateSkin
()
{
this
.
_skin
.
x
=
this
.
position
[
0
]
*
FACTOR
;
this
.
_skin
.
y
=
this
.
position
[
1
]
*
FACTOR
;
this
.
_skin
.
rotation
=
this
.
angle
*
180
/
Math
.
PI
;
}
get
skin
()
{
return
this
.
_skin
}
}
\ 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