Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
new-kickball
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
wildfirecode13
new-kickball
Commits
332535bf
Commit
332535bf
authored
Jun 03, 2019
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
c5423766
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
202 additions
and
86 deletions
+202
-86
.scilla
.scilla
+1
-1
BallItem.pfb
assets/prefabs/BallItem.pfb
+9
-2
main.scene
assets/scenes/main.scene
+54
-5
BallItem.ts
assets/scripts/scenes/BallItem.ts
+4
-5
BulletItem.ts
assets/scripts/scenes/BulletItem.ts
+1
-1
ScenePlay.ts
assets/scripts/scenes/ScenePlay.ts
+50
-45
CarBulletAni.ts
assets/scripts/scenes/scenePlay/CarBulletAni.ts
+82
-26
CarShootAni.ts
assets/scripts/scenes/scenePlay/CarShootAni.ts
+1
-1
No files found.
.scilla
View file @
332535bf
{"currentScene":"assets/scenes/main.scene"}
\ No newline at end of file
{"currentScene":"assets/prefabs/BallItem.pfb"}
\ No newline at end of file
assets/prefabs/BallItem.pfb
View file @
332535bf
...
...
@@ -112,7 +112,13 @@
"components": [
{
"script": "components/base/Transform",
"properties": {}
"properties": {
"position": {
"_hashCode": 44907,
"_x": 0,
"_y": 0
}
}
},
{
"script": "components/renderer/TextureRenderer",
...
...
@@ -121,7 +127,8 @@
}
}
],
"uuid": "47a489b3-037f-4f2d-87bb-58e1b962afb0"
"uuid": "47a489b3-037f-4f2d-87bb-58e1b962afb0",
"disabled": false
},
{
"name": "txt",
...
...
assets/scenes/main.scene
View file @
332535bf
...
...
@@ -111,7 +111,8 @@
}
}
],
"uuid": "34cfbf69-3216-4aef-9d99-936659fbca19"
"uuid": "34cfbf69-3216-4aef-9d99-936659fbca19",
"disabled": false
},
{
"name": "Label",
...
...
@@ -391,7 +392,9 @@
"BulletItemPrefab": "res|df59e078-e7b7-4fbb-a1aa-8b291284c39f",
"YellowRocketPrefab": "res|51834a6b-5880-41df-81d9-beaef804a919",
"doJoinData": "dynamic|API|doJoin",
"getNgameStartStatus": "dynamic|API|ngameSubmit"
"getNgameStartStatus": "dynamic|API|ngameSubmit",
"bottomline": "entity|791444c1-84e8-4455-9fb1-c1b2691c6cc0",
"topline": "entity|9f9bfbf2-4f77-4a1b-b1b5-42b6784e0c8c"
}
}
],
...
...
@@ -572,8 +575,8 @@
"script": "components/base/Transform",
"properties": {
"position": {
"x": -
207.5
,
"y":
340
,
"x": -
44.16666666666666
,
"y":
473.33333333333337
,
"_type_": "scilla/support/Vector2D"
}
}
...
...
@@ -584,7 +587,7 @@
"width": 120,
"height": 110
},
"disabled":
fals
e
"disabled":
tru
e
},
{
"script": "./scripts/scenes/scenePlay/CarBulletAni",
...
...
@@ -732,6 +735,52 @@
]
}
]
},
{
"name": "topline",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 0,
"y": -256.6666666666667
}
}
},
{
"script": "components/renderer/RectRenderer",
"properties": {
"width": 750,
"fillColor": "rgba(255, 0, 0, 1)",
"height": 5
}
}
],
"uuid": "9f9bfbf2-4f77-4a1b-b1b5-42b6784e0c8c"
},
{
"name": "buttomLine",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 0,
"y": 540
}
}
},
{
"script": "components/renderer/RectRenderer",
"properties": {
"width": 750,
"height": 5,
"fillColor": "rgba(255, 0, 0, 1)"
}
}
],
"uuid": "791444c1-84e8-4455-9fb1-c1b2691c6cc0"
}
],
"disabled": true
...
...
assets/scripts/scenes/BallItem.ts
View file @
332535bf
import
Body
from
'./Body'
;
import
{
gravityY
}
from
'./gameconst'
;
import
{
Entity
}
from
'scilla/src'
;
import
{
TextRenderer
}
from
'scilla-components/src'
;
import
{
Entity
}
from
'scilla/src'
;
import
Body
from
'./Body'
;
export
default
class
BallItem
extends
Body
{
score
=
0
;
...
...
@@ -9,8 +8,8 @@ export default class BallItem extends Body {
isBig
=
true
;
constructor
()
{
super
();
this
.
gravity
=
gravityY
;
this
.
rotationSpeed
=
0.5
;
this
.
gravity
=
0.225
;
this
.
rotationSpeed
=
0.5
;
s
}
onAwake
()
{
...
...
assets/scripts/scenes/BulletItem.ts
View file @
332535bf
...
...
@@ -4,7 +4,7 @@ export default class BulletItem extends Body {
constructor
()
{
super
();
this
.
gravity
=
0
;
this
.
velocityY
=
-
1
0
;
this
.
velocityY
=
-
2
0
;
this
.
rotationSpeed
=
0
;
}
}
\ No newline at end of file
assets/scripts/scenes/ScenePlay.ts
View file @
332535bf
import
ScillaComponent
from
"scilla-components/src/base/Scilla
Component"
;
import
InteractComponent
from
"scilla-components/src/base/Interact
Component"
;
import
Transform
from
"scilla-components/src/base/Transform"
;
import
{
dynamic
,
Entity
,
instantiate
,
resource
}
from
"scilla/src"
;
import
{
getTween
}
from
'../getTween'
;
import
{
alien
}
from
"../navigator/StackNavigator"
;
import
{
INavigatorViewBase
}
from
"../navigator/VirtualNavigator"
;
import
{
createSgin
}
from
"../net/webService"
;
import
{
getX
,
getY
,
setX
Y
,
setX
}
from
"../transformUtils"
;
import
{
getX
,
getY
,
setX
,
setXY
}
from
"../transformUtils"
;
import
BallItem
from
"./BallItem"
;
import
Body
from
"./Body"
;
import
{
removeFromList
}
from
"./_"
;
import
InteractComponent
from
"scilla-components/src/base/InteractComponent"
;
import
CarShootAni
from
"./scenePlay/CarShootAni"
;
import
CarBulletAni
from
"./scenePlay/CarBulletAni"
;
import
CarShootAni
from
"./scenePlay/CarShootAni"
;
import
{
removeFromList
}
from
"./_"
;
export
default
class
ScenePlay
extends
InteractComponent
implements
INavigatorViewBase
{
BallItemPrefab
:
resource
;
...
...
@@ -23,6 +22,8 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
bulletNumTxt
:
Entity
;
strengthNumTxt
:
Entity
;
car
:
Entity
;
topline
:
Entity
;
bottomline
:
Entity
;
doJoinData
:
dynamic
;
getNgameStartStatus
:
dynamic
;
...
...
@@ -31,15 +32,13 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
bodys
:
Body
[];
ballList
:
Body
[];
drops
:
Body
[];
bullets
:
Body
[];
// freeBullets: Body[];
_carShootAni
:
CarShootAni
;
_carBulletAni
:
CarBulletAni
;
//
onGlobalTouchBegin(e): any {
// setX(this.car, e.x - 375)
;
//
return super.onGlobalTouchBegin(e);
//
}
onGlobalTouchBegin
(
e
):
any
{
this
.
_lastTouchMoveX
=-
1
;
return
super
.
onGlobalTouchBegin
(
e
);
}
_lastTouchMoveX
=
-
1
;
onGlobalTouchMove
(
e
:
{
x
,
y
})
{
...
...
@@ -58,27 +57,31 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
}
onUpdate
()
{
this
.
checkRemoveBullets
();
}
// removeBullet(body: Body) {
// body.entity.enabled = false;
// this.entity.removeChild(body.entity);
// removeFromList(body, this.bodys);
// removeFromList(body, this.bullets);
// this.freeBullets.push(body);
// // console.log(this.bullets.length, this.freeBullets.length)
// }
checkRemoveBullets
()
{
// for (let i = 0; i < this.bullets.length; i++) {
// const bullet = this.bullets[i];
// const y = getY(bullet.entity)
// if (y < -1624 / 2) { //子弹失效
// this.removeBullet(bullet);
// i--;
// }
// }
this
.
checkBallCollideGroud
();
}
checkBallCollideGroud
()
{
for
(
let
i
=
0
;
i
<
this
.
ballList
.
length
;
i
++
)
{
const
ball
=
this
.
ballList
[
i
];
const
{
position
}
=
ball
.
getComponent
(
Transform
);
const
pic
=
ball
.
entity
.
getChildrenByName
(
'blue'
)[
0
];
const
{
height
,
scale
}
=
pic
.
getComponent
(
Transform
);
const
r
=
height
/
2
*
scale
.
y
;
//刚体的半径
if
(
position
.
y
+
r
>
getY
(
this
.
bottomline
))
{
position
.
y
=
getY
(
this
.
bottomline
)
-
r
;
ball
.
revertY
();
ball
.
velocityY
=
-
17.54
;
}
if
(
position
.
x
+
r
>
375
)
{
position
.
x
=
375
-
r
;
ball
.
revertX
();
}
if
(
position
.
x
-
r
<
-
375
)
{
position
.
x
=
-
375
+
r
;
ball
.
revertX
();
}
}
}
onDrops
(
ball
:
Body
)
{
...
...
@@ -93,10 +96,15 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
return
item
;
}
bulletCreated
(
bullet
:
Body
)
{
this
.
entity
.
addChild
(
bullet
.
entity
);
this
.
bodys
.
push
(
bullet
);
this
.
bullets
.
push
(
bullet
);
bulletRemoved
(
body
:
Body
)
{
removeFromList
(
body
,
this
.
bodys
);
}
bulletCreated
(
bullets
:
Body
[])
{
bullets
.
forEach
(
bullet
=>
{
this
.
entity
.
addChild
(
bullet
.
entity
);
this
.
bodys
.
push
(
bullet
);
});
}
getFireItem
(
res
:
resource
)
{
...
...
@@ -109,11 +117,12 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
}
async
createBigBall
()
{
let
dir
=
Math
.
random
()
>
0.5
?
-
1
:
1
;
const
ball
=
this
.
getBallItem
(
20
);
setXY
(
ball
.
entity
,
-
375
,
-
400
);
setXY
(
ball
.
entity
,
-
375
,
getY
(
this
.
topline
)
+
400
);
const
body
=
ball
.
getComponent
(
Body
);
body
.
enabled
=
false
;
await
getTween
(
this
,
ball
.
getComponent
(
Transform
),
{
x
:
-
375
+
200
},
10
00
);
await
getTween
(
this
,
ball
.
getComponent
(
Transform
),
{
x
:
-
375
+
200
},
7
00
);
body
.
velocityX
=
5
;
body
.
enabled
=
true
;
}
...
...
@@ -133,8 +142,6 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
this
.
bodys
=
[];
this
.
ballList
=
[];
this
.
drops
=
[];
this
.
bullets
=
[];
// this.freeBullets = [];
this
.
_carShootAni
=
this
.
car
.
getComponent
(
CarShootAni
);
this
.
_carBulletAni
=
this
.
car
.
getComponent
(
CarBulletAni
);
}
...
...
@@ -146,11 +153,9 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
// this.onGameOver();
// }, 3000);
// setInterval(() => { this.createBullet() }, 1000 / 10);
// setInterval(() => {
// this.createBigBall();
// }, 3000);
setInterval
(()
=>
{
this
.
createBigBall
();
},
2000
);
}
onGameOver
()
{
...
...
assets/scripts/scenes/scenePlay/CarBulletAni.ts
View file @
332535bf
import
{
getTween
}
from
'assets/scripts/getTween'
;
import
{
getX
,
getY
,
setXY
}
from
'assets/scripts/transformUtils'
;
import
ScillaComponent
from
'components/base/ScillaComponent'
;
import
{
Transform
}
from
'scilla-components/src'
;
import
{
Entity
,
instantiate
,
resource
}
from
'scilla/src'
;
import
Body
from
'../Body'
;
import
{
setXY
,
getX
,
getY
}
from
'assets/scripts/transformUtils'
;
import
{
removeFromList
}
from
'../_'
;
const
getLines
=
(
X
)
=>
{
if
(
X
<=
20
)
return
1
if
(
X
<=
40
)
return
2
if
(
X
<=
60
)
return
3
if
(
X
<=
80
)
return
4
if
(
X
<=
100
)
return
5
if
(
X
<=
120
)
return
6
if
(
X
<=
140
)
return
7
return
7
}
export
default
class
CarBulletAni
extends
ScillaComponent
{
BulletItemPrefab
:
resource
;
private
_interval
=
10
;
private
_interval
=
3
;
//等级1 2 3 4
private
_level
:
number
;
freeBullets
:
Body
[];
private
_lines
=
7
;
private
_offsetList
:
number
[][]
=
[];
bullets
:
Body
[]
=
[];
private
_freeBullets
:
Body
[];
private
_playScene
:
Entity
;
onAwake
()
{
super
.
onAwake
();
this
.
freeBullets
=
[];
this
.
_freeBullets
=
[];
this
.
_offsetList
.
push
([
0
]);
this
.
_offsetList
.
push
([
-
9
,
9
]);
this
.
_offsetList
.
push
([
-
18
,
0
,
18
]);
this
.
_offsetList
.
push
([
-
27
,
-
9
,
9
,
27
]);
this
.
_offsetList
.
push
([
-
36
,
-
18
,
0
,
18
,
36
]);
this
.
_offsetList
.
push
([
-
45
,
-
27
,
-
9
,
9
,
27
,
45
]);
this
.
_offsetList
.
push
([
-
54
,
-
36
,
-
18
,
0
,
18
,
36
,
54
]);
this
.
_playScene
=
this
.
entity
.
parent
;
}
updateLines
(
X
)
{
this
.
_lines
=
getLines
(
x
);
}
_counter
=
0
;
onUpdate
(
t
)
{
super
.
onUpdate
(
t
);
this
.
_counter
++
;
if
(
this
.
_counter
>
this
.
_interval
)
{
if
(
this
.
_counter
>
=
this
.
_interval
)
{
this
.
_counter
=
0
;
this
.
createBullet
();
}
this
.
checkRemoveBullets
();
}
removeBullet
(
body
:
Body
)
{
// body.entity.enabled = false;
// this.entity.removeChild(body.entity);
// removeFromList(body, this.bodys);
// removeFromList(body, this.bullets);
// this.freeBullets.push(body);
body
.
entity
.
enabled
=
false
;
this
.
_playScene
.
removeChild
(
body
.
entity
);
removeFromList
(
body
,
this
.
bullets
);
this
.
_freeBullets
.
push
(
body
);
this
.
bubbling
(
'bulletRemoved'
,
body
);
// console.log(this._freeBullets.length, this._bullets.length);
}
checkRemoveBullets
()
{
for
(
let
i
=
0
;
i
<
this
.
bullets
.
length
;
i
++
)
{
const
bullet
=
this
.
bullets
[
i
];
const
y
=
getY
(
bullet
.
entity
)
if
(
y
<
-
1624
/
2
)
{
//子弹失效
this
.
removeBullet
(
bullet
);
i
--
;
}
}
}
createBullet
()
{
let
bullet
:
Body
;
let
item
:
Entity
;
if
(
this
.
freeBullets
.
length
>
0
)
{
bullet
=
this
.
freeBullets
.
pop
();
item
=
bullet
.
entity
;
item
.
enabled
=
true
;
}
else
{
item
=
instantiate
(
this
.
BulletItemPrefab
);
bullet
=
item
.
getComponent
(
Body
);
const
tweens
=
[];
const
list
:
Body
[]
=
[];
const
offsets
=
this
.
_offsetList
[
this
.
_lines
-
1
];
for
(
let
i
=
0
;
i
<
this
.
_lines
;
i
++
)
{
let
bullet
:
Body
;
let
item
:
Entity
;
if
(
this
.
_freeBullets
.
length
>
0
)
{
bullet
=
this
.
_freeBullets
.
pop
();
item
=
bullet
.
entity
;
item
.
enabled
=
true
;
}
else
{
item
=
instantiate
(
this
.
BulletItemPrefab
);
bullet
=
item
.
getComponent
(
Body
);
}
bullet
.
enabled
=
false
;
//先禁用物理
list
.
push
(
bullet
);
this
.
bullets
.
push
(
bullet
);
const
targetX
=
getX
(
this
.
entity
);
const
targetY
=
getY
(
this
.
entity
)
-
100
;
setXY
(
item
,
targetX
,
targetY
);
const
tween
=
getTween
(
this
,
item
.
getComponent
(
Transform
),
{
y
:
targetY
-
60
,
x
:
targetX
+
offsets
[
i
]
},
100
);
tweens
.
push
(
tween
);
}
// this.entity.addChild(item);
// this.bodys.push(bullet);
// this.bullets.push(bullet);
console
.
log
(
getX
(
this
.
entity
),
getY
(
this
.
entity
)
-
100
);
setXY
(
item
,
getX
(
this
.
entity
),
getY
(
this
.
entity
)
-
100
);
this
.
bubbling
(
'bulletCreated'
,
bullet
);
Promise
.
all
(
tweens
).
then
(()
=>
{
list
.
forEach
(
item
=>
item
.
enabled
=
true
);
});
this
.
bubbling
(
'bulletCreated'
,
list
);
}
}
assets/scripts/scenes/scenePlay/CarShootAni.ts
View file @
332535bf
...
...
@@ -18,7 +18,7 @@ export default class CarShootAni extends ScillaComponent {
if
(
this
.
_counter
>
1
)
{
this
.
_counter
=
0
;
const
bodyY
=
getY
(
this
.
body
);
const
targetY
=
bodyY
==
this
.
_bodyY
?
this
.
_bodyY
+
3
:
this
.
_bodyY
;
const
targetY
=
bodyY
==
this
.
_bodyY
?
this
.
_bodyY
-
3
:
this
.
_bodyY
;
setY
(
this
.
body
,
targetY
);
this
.
smoke
.
enabled
=
!
this
.
smoke
.
enabled
;
}
...
...
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