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';
export
default
class
Body
extends
ScillaComponent
{
bounceY
=
0
;
private
_velocityY
=
0
;
velocityY
=
0
;
velocityX
=
0
;
onUpdate
()
{
const
{
entity
}
=
this
;
this
.
_velocityY
+=
gravityY
;
entity
.
getComponent
(
Transform
).
position
.
y
+=
this
.
_velocityY
;
this
.
velocityY
+=
gravityY
;
entity
.
getComponent
(
Transform
).
position
.
y
+=
this
.
velocityY
;
entity
.
getComponent
(
Transform
).
position
.
x
+=
this
.
velocityX
;
}
revertY
()
{
this
.
_velocityY
*=
-
1
*
this
.
bounceY
;
console
.
log
(
this
.
_velocityY
)
this
.
velocityY
*=
-
1
*
this
.
bounceY
;
}
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
ScillaComponent
from
'scilla-components/src/base/ScillaComponent'
;
export
default
class
RedFireItem
extends
ScillaComponent
{
constructor
()
{
super
();
}
export
default
class
RedFireItem
extends
Body
{
}
\ 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';
import
{
alien
}
from
"../navigator/StackNavigator"
;
import
{
INavigatorViewBase
}
from
"../navigator/VirtualNavigator"
;
import
BallItem
from
'./BallItem'
;
import
RedFireItem
from
'./RedFireItem'
;
import
Body
from
'./Body'
;
const
GROUND_Y
=
250
;
//碰到地板时,球的中心点的y
export
default
class
ScenePlay
extends
ScillaComponent
implements
INavigatorViewBase
{
BallItemPrefab
:
resource
;
RedFirePrefab
:
resource
;
bulletNumTxt
:
Entity
;
strengthNumTxt
:
Entity
;
ballList
:
Entity
[];
redFireList
:
Entity
[];
// ballList: Entity[];
// redFireList: Entity[];
bodys
:
Entity
[];
getRedFireItem
()
{
const
redFire
=
instantiate
(
this
.
RedFirePrefab
);
this
.
entity
.
addChild
(
redFire
);
this
.
redFireList
.
push
(
redFire
);
// (redFire.getComponent(RedFireItem) as RedFireItem).bounceY = 0.9;
this
.
bodys
.
push
(
redFire
);
// this.redFireList.push(redFire);
redFire
.
getComponent
(
RedFireItem
).
bounceY
=
0.9
;
// redFire.getComponent(RedFireItem).
}
getBallItem
()
{
const
ball
=
instantiate
(
this
.
BallItemPrefab
);
this
.
entity
.
addChild
(
ball
);
this
.
ballList
.
push
(
ball
);
console
.
log
(
ball
.
getComponent
(
Transform
).
position
.
y
);
(
ball
.
getComponent
(
BallItem
)
as
BallItem
).
bounceY
=
1
;
//
this.ballList.push(ball);
this
.
bodys
.
push
(
ball
);
ball
.
getComponent
(
BallItem
).
bounceY
=
1
;
}
onAwake
()
{
super
.
onAwake
();
this
.
ballList
=
[];
// this.ballList = [];
this
.
bodys
=
[];
}
onUpdate
()
{
for
(
const
b
all
of
this
.
ballList
)
{
const
{
position
}
=
b
all
.
getComponent
(
Transform
);
for
(
const
b
ody
of
this
.
bodys
)
{
const
{
position
}
=
b
ody
.
getComponent
(
Transform
);
if
(
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 @@
function
Body
()
{
var
_this
=
_super
!==
null
&&
_super
.
apply
(
this
,
arguments
)
||
this
;
_this
.
bounceY
=
0
;
_this
.
_velocityY
=
0
;
_this
.
velocityY
=
0
;
_this
.
velocityX
=
0
;
return
_this
;
}
Body
.
prototype
.
onUpdate
=
function
()
{
var
entity
=
this
.
entity
;
this
.
_velocityY
+=
gravityY
;
entity
.
getComponent
(
Transform
).
position
.
y
+=
this
.
_velocityY
;
this
.
velocityY
+=
gravityY
;
entity
.
getComponent
(
Transform
).
position
.
y
+=
this
.
velocityY
;
entity
.
getComponent
(
Transform
).
position
.
x
+=
this
.
velocityX
;
};
Body
.
prototype
.
revertY
=
function
()
{
this
.
_velocityY
*=
-
1
*
this
.
bounceY
;
console
.
log
(
this
.
_velocityY
);
this
.
velocityY
*=
-
1
*
this
.
bounceY
;
};
Body
.
prototype
.
revertX
=
function
()
{
this
.
velocityX
*=
-
1
*
this
.
bounceY
;
};
return
Body
;
}(
ScillaComponent
));
...
...
@@ -7113,6 +7117,14 @@
return
BallItem
;
}(
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
ScenePlay
=
(
function
(
_super
)
{
__extends
(
ScenePlay
,
_super
);
...
...
@@ -7122,28 +7134,28 @@
ScenePlay
.
prototype
.
getRedFireItem
=
function
()
{
var
redFire
=
instantiate
(
this
.
RedFirePrefab
);
this
.
entity
.
addChild
(
redFire
);
this
.
redFireList
.
push
(
redFire
);
this
.
bodys
.
push
(
redFire
);
redFire
.
getComponent
(
RedFireItem
).
bounceY
=
0.9
;
};
ScenePlay
.
prototype
.
getBallItem
=
function
()
{
var
ball
=
instantiate
(
this
.
BallItemPrefab
);
this
.
entity
.
addChild
(
ball
);
this
.
ballList
.
push
(
ball
);
console
.
log
(
ball
.
getComponent
(
Transform
).
position
.
y
);
this
.
bodys
.
push
(
ball
);
ball
.
getComponent
(
BallItem
).
bounceY
=
1
;
};
ScenePlay
.
prototype
.
onAwake
=
function
()
{
_super
.
prototype
.
onAwake
.
call
(
this
);
this
.
b
allList
=
[];
this
.
b
odys
=
[];
};
ScenePlay
.
prototype
.
onUpdate
=
function
()
{
var
e_1
,
_a
;
try
{
for
(
var
_b
=
__values
(
this
.
b
allList
),
_c
=
_b
.
next
();
!
_c
.
done
;
_c
=
_b
.
next
())
{
var
b
all
=
_c
.
value
;
var
position
=
b
all
.
getComponent
(
Transform
).
position
;
for
(
var
_b
=
__values
(
this
.
b
odys
),
_c
=
_b
.
next
();
!
_c
.
done
;
_c
=
_b
.
next
())
{
var
b
ody
=
_c
.
value
;
var
position
=
b
ody
.
getComponent
(
Transform
).
position
;
if
(
position
.
y
>
GROUND_Y
)
{
position
.
y
=
GROUND_Y
;
b
all
.
getComponent
(
BallItem
).
revertY
();
b
ody
.
getComponent
(
Body
).
revertY
();
}
}
}
...
...
@@ -7445,14 +7457,6 @@
return
testC
;
}(
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/base/Transform'
,
Transform
);
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