Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scilla-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
scilla-kickball
Commits
87ed75e2
Commit
87ed75e2
authored
Apr 23, 2019
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
f6ab2664
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
44 deletions
+55
-44
.DS_Store
.DS_Store
+0
-0
Body.ts
assets/scripts/scenes/Body.ts
+9
-5
RedFireItem.ts
assets/scripts/scenes/RedFireItem.ts
+2
-5
ScenePlay.ts
assets/scripts/scenes/ScenePlay.ts
+18
-12
bundle.js
debug/bundle.js
+25
-21
bundle.js.map
debug/bundle.js.map
+1
-1
No files found.
.DS_Store
0 → 100644
View file @
87ed75e2
File added
assets/scripts/scenes/Body.ts
View file @
87ed75e2
...
@@ -4,15 +4,19 @@ import { gravityY } from './gameconst';
...
@@ -4,15 +4,19 @@ import { gravityY } from './gameconst';
export
default
class
Body
extends
ScillaComponent
{
export
default
class
Body
extends
ScillaComponent
{
bounceY
=
0
;
bounceY
=
0
;
private
_velocityY
=
0
;
velocityY
=
0
;
velocityX
=
0
;
onUpdate
()
{
onUpdate
()
{
const
{
entity
}
=
this
;
const
{
entity
}
=
this
;
this
.
_velocityY
+=
gravityY
;
this
.
velocityY
+=
gravityY
;
entity
.
getComponent
(
Transform
).
position
.
y
+=
this
.
_velocityY
;
entity
.
getComponent
(
Transform
).
position
.
y
+=
this
.
velocityY
;
entity
.
getComponent
(
Transform
).
position
.
x
+=
this
.
velocityX
;
}
}
revertY
()
{
revertY
()
{
this
.
_velocityY
*=
-
1
*
this
.
bounceY
;
this
.
velocityY
*=
-
1
*
this
.
bounceY
;
console
.
log
(
this
.
_velocityY
)
}
revertX
()
{
this
.
velocityX
*=
-
1
*
this
.
bounceY
;
}
}
}
}
\ No newline at end of file
assets/scripts/scenes/RedFireItem.ts
View file @
87ed75e2
import
Body
from
'./Body'
;
import
Body
from
'./Body'
;
import
ScillaComponent
from
'scilla-components/src/base/ScillaComponent'
;
export
default
class
RedFireItem
extends
ScillaComponent
{
export
default
class
RedFireItem
extends
Body
{
constructor
()
{
super
();
}
}
}
\ No newline at end of file
assets/scripts/scenes/ScenePlay.ts
View file @
87ed75e2
...
@@ -7,43 +7,49 @@ import ScillaComponent from 'scilla-components/src/base/ScillaComponent';
...
@@ -7,43 +7,49 @@ import ScillaComponent from 'scilla-components/src/base/ScillaComponent';
import
{
alien
}
from
"../navigator/StackNavigator"
;
import
{
alien
}
from
"../navigator/StackNavigator"
;
import
{
INavigatorViewBase
}
from
"../navigator/VirtualNavigator"
;
import
{
INavigatorViewBase
}
from
"../navigator/VirtualNavigator"
;
import
BallItem
from
'./BallItem'
;
import
BallItem
from
'./BallItem'
;
import
RedFireItem
from
'./RedFireItem'
;
import
Body
from
'./Body'
;
const
GROUND_Y
=
250
;
//碰到地板时,球的中心点的y
const
GROUND_Y
=
250
;
//碰到地板时,球的中心点的y
export
default
class
ScenePlay
extends
ScillaComponent
implements
INavigatorViewBase
{
export
default
class
ScenePlay
extends
ScillaComponent
implements
INavigatorViewBase
{
BallItemPrefab
:
resource
;
BallItemPrefab
:
resource
;
RedFirePrefab
:
resource
;
RedFirePrefab
:
resource
;
bulletNumTxt
:
Entity
;
bulletNumTxt
:
Entity
;
strengthNumTxt
:
Entity
;
strengthNumTxt
:
Entity
;
ballList
:
Entity
[];
// ballList: Entity[];
redFireList
:
Entity
[];
// redFireList: Entity[];
bodys
:
Entity
[];
getRedFireItem
()
{
getRedFireItem
()
{
const
redFire
=
instantiate
(
this
.
RedFirePrefab
);
const
redFire
=
instantiate
(
this
.
RedFirePrefab
);
this
.
entity
.
addChild
(
redFire
);
this
.
entity
.
addChild
(
redFire
);
this
.
redFireList
.
push
(
redFire
);
this
.
bodys
.
push
(
redFire
);
// (redFire.getComponent(RedFireItem) as RedFireItem).bounceY = 0.9;
// this.redFireList.push(redFire);
redFire
.
getComponent
(
RedFireItem
).
bounceY
=
0.9
;
// redFire.getComponent(RedFireItem).
}
}
getBallItem
()
{
getBallItem
()
{
const
ball
=
instantiate
(
this
.
BallItemPrefab
);
const
ball
=
instantiate
(
this
.
BallItemPrefab
);
this
.
entity
.
addChild
(
ball
);
this
.
entity
.
addChild
(
ball
);
this
.
ballList
.
push
(
ball
);
//
this.ballList.push(ball);
console
.
log
(
ball
.
getComponent
(
Transform
).
position
.
y
);
this
.
bodys
.
push
(
ball
);
(
ball
.
getComponent
(
BallItem
)
as
BallItem
).
bounceY
=
1
;
ball
.
getComponent
(
BallItem
).
bounceY
=
1
;
}
}
onAwake
()
{
onAwake
()
{
super
.
onAwake
();
super
.
onAwake
();
this
.
ballList
=
[];
// this.ballList = [];
this
.
bodys
=
[];
}
}
onUpdate
()
{
onUpdate
()
{
for
(
const
b
all
of
this
.
ballList
)
{
for
(
const
b
ody
of
this
.
bodys
)
{
const
{
position
}
=
b
all
.
getComponent
(
Transform
);
const
{
position
}
=
b
ody
.
getComponent
(
Transform
);
if
(
position
.
y
>
GROUND_Y
)
{
if
(
position
.
y
>
GROUND_Y
)
{
position
.
y
=
GROUND_Y
;
position
.
y
=
GROUND_Y
;
(
ball
.
getComponent
(
BallItem
)
as
BallItem
).
revertY
();
body
.
getComponent
(
Body
).
revertY
();
}
}
}
}
}
}
...
...
debug/bundle.js
View file @
87ed75e2
...
@@ -7090,17 +7090,21 @@
...
@@ -7090,17 +7090,21 @@
function
Body
()
{
function
Body
()
{
var
_this
=
_super
!==
null
&&
_super
.
apply
(
this
,
arguments
)
||
this
;
var
_this
=
_super
!==
null
&&
_super
.
apply
(
this
,
arguments
)
||
this
;
_this
.
bounceY
=
0
;
_this
.
bounceY
=
0
;
_this
.
_velocityY
=
0
;
_this
.
velocityY
=
0
;
_this
.
velocityX
=
0
;
return
_this
;
return
_this
;
}
}
Body
.
prototype
.
onUpdate
=
function
()
{
Body
.
prototype
.
onUpdate
=
function
()
{
var
entity
=
this
.
entity
;
var
entity
=
this
.
entity
;
this
.
_velocityY
+=
gravityY
;
this
.
velocityY
+=
gravityY
;
entity
.
getComponent
(
Transform
).
position
.
y
+=
this
.
_velocityY
;
entity
.
getComponent
(
Transform
).
position
.
y
+=
this
.
velocityY
;
entity
.
getComponent
(
Transform
).
position
.
x
+=
this
.
velocityX
;
};
};
Body
.
prototype
.
revertY
=
function
()
{
Body
.
prototype
.
revertY
=
function
()
{
this
.
_velocityY
*=
-
1
*
this
.
bounceY
;
this
.
velocityY
*=
-
1
*
this
.
bounceY
;
console
.
log
(
this
.
_velocityY
);
};
Body
.
prototype
.
revertX
=
function
()
{
this
.
velocityX
*=
-
1
*
this
.
bounceY
;
};
};
return
Body
;
return
Body
;
}(
ScillaComponent
));
}(
ScillaComponent
));
...
@@ -7113,6 +7117,14 @@
...
@@ -7113,6 +7117,14 @@
return
BallItem
;
return
BallItem
;
}(
Body
));
}(
Body
));
var
RedFireItem
=
(
function
(
_super
)
{
__extends
(
RedFireItem
,
_super
);
function
RedFireItem
()
{
return
_super
!==
null
&&
_super
.
apply
(
this
,
arguments
)
||
this
;
}
return
RedFireItem
;
}(
Body
));
var
GROUND_Y
=
250
;
var
GROUND_Y
=
250
;
var
ScenePlay
=
(
function
(
_super
)
{
var
ScenePlay
=
(
function
(
_super
)
{
__extends
(
ScenePlay
,
_super
);
__extends
(
ScenePlay
,
_super
);
...
@@ -7122,28 +7134,28 @@
...
@@ -7122,28 +7134,28 @@
ScenePlay
.
prototype
.
getRedFireItem
=
function
()
{
ScenePlay
.
prototype
.
getRedFireItem
=
function
()
{
var
redFire
=
instantiate
(
this
.
RedFirePrefab
);
var
redFire
=
instantiate
(
this
.
RedFirePrefab
);
this
.
entity
.
addChild
(
redFire
);
this
.
entity
.
addChild
(
redFire
);
this
.
redFireList
.
push
(
redFire
);
this
.
bodys
.
push
(
redFire
);
redFire
.
getComponent
(
RedFireItem
).
bounceY
=
0.9
;
};
};
ScenePlay
.
prototype
.
getBallItem
=
function
()
{
ScenePlay
.
prototype
.
getBallItem
=
function
()
{
var
ball
=
instantiate
(
this
.
BallItemPrefab
);
var
ball
=
instantiate
(
this
.
BallItemPrefab
);
this
.
entity
.
addChild
(
ball
);
this
.
entity
.
addChild
(
ball
);
this
.
ballList
.
push
(
ball
);
this
.
bodys
.
push
(
ball
);
console
.
log
(
ball
.
getComponent
(
Transform
).
position
.
y
);
ball
.
getComponent
(
BallItem
).
bounceY
=
1
;
ball
.
getComponent
(
BallItem
).
bounceY
=
1
;
};
};
ScenePlay
.
prototype
.
onAwake
=
function
()
{
ScenePlay
.
prototype
.
onAwake
=
function
()
{
_super
.
prototype
.
onAwake
.
call
(
this
);
_super
.
prototype
.
onAwake
.
call
(
this
);
this
.
b
allList
=
[];
this
.
b
odys
=
[];
};
};
ScenePlay
.
prototype
.
onUpdate
=
function
()
{
ScenePlay
.
prototype
.
onUpdate
=
function
()
{
var
e_1
,
_a
;
var
e_1
,
_a
;
try
{
try
{
for
(
var
_b
=
__values
(
this
.
b
allList
),
_c
=
_b
.
next
();
!
_c
.
done
;
_c
=
_b
.
next
())
{
for
(
var
_b
=
__values
(
this
.
b
odys
),
_c
=
_b
.
next
();
!
_c
.
done
;
_c
=
_b
.
next
())
{
var
b
all
=
_c
.
value
;
var
b
ody
=
_c
.
value
;
var
position
=
b
all
.
getComponent
(
Transform
).
position
;
var
position
=
b
ody
.
getComponent
(
Transform
).
position
;
if
(
position
.
y
>
GROUND_Y
)
{
if
(
position
.
y
>
GROUND_Y
)
{
position
.
y
=
GROUND_Y
;
position
.
y
=
GROUND_Y
;
b
all
.
getComponent
(
BallItem
).
revertY
();
b
ody
.
getComponent
(
Body
).
revertY
();
}
}
}
}
}
}
...
@@ -7445,14 +7457,6 @@
...
@@ -7445,14 +7457,6 @@
return
testC
;
return
testC
;
}(
ScillaComponent
));
}(
ScillaComponent
));
var
RedFireItem
=
(
function
(
_super
)
{
__extends
(
RedFireItem
,
_super
);
function
RedFireItem
()
{
return
_super
.
call
(
this
)
||
this
;
}
return
RedFireItem
;
}(
ScillaComponent
));
registerDef
(
'components/animation/TouchZoom'
,
TouchZoom
);
registerDef
(
'components/animation/TouchZoom'
,
TouchZoom
);
registerDef
(
'components/base/Transform'
,
Transform
);
registerDef
(
'components/base/Transform'
,
Transform
);
registerDef
(
'components/renderer/RectRenderer'
,
RectRenderer
);
registerDef
(
'components/renderer/RectRenderer'
,
RectRenderer
);
...
...
debug/bundle.js.map
View file @
87ed75e2
This diff is collapsed.
Click to expand it.
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