Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
playground
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
wildfirecode13
playground
Commits
9abebb1e
Commit
9abebb1e
authored
Feb 13, 2021
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
eb25a193
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
15 deletions
+41
-15
DropItem.js
test/src/game/DropItem.js
+14
-6
main.js
test/src/game/main.js
+27
-9
No files found.
test/src/game/DropItem.js
View file @
9abebb1e
import
{
Sprite
,
TextureCache
}
from
'spark-wrapper-fyge'
;
export
default
class
DropItem
extends
Sprite
{
constructor
()
{
constructor
(
props
)
{
super
();
this
.
texture
=
TextureCache
[
'box'
]
this
.
y
=
0
;
this
.
texture
=
TextureCache
[
'box'
];
this
.
velocityX
=
this
.
initialVelocityX
=
props
.
initialVelocityX
||
0
;
this
.
velocityY
=
this
.
initialVelocityY
=
props
.
initialVelocityY
||
0
;
this
.
accelerationX
=
props
.
accelerationX
||
0
;
this
.
accelerationY
=
props
.
accelerationY
||
0
;
}
updatePosition
()
{
this
.
y
+=
10
;
onEnterFrame
()
{
this
.
velocityX
+=
this
.
accelerationX
;
this
.
velocityY
+=
this
.
accelerationY
;
this
.
x
+=
this
.
velocityX
;
this
.
y
+=
this
.
velocityY
;
}
}
test/src/game/main.js
View file @
9abebb1e
import
{
WidgetBase
}
from
'spark-wrapper-fyge'
;
import
{
WidgetBase
,
Event
}
from
'spark-wrapper-fyge'
;
import
metaConfig
from
'../meta.json'
;
import
Root
from
'./Root'
;
import
DropItem
from
'./DropItem'
;
/**
*
*
*/
class
GameStage
extends
WidgetBase
{
onLaunched
()
{
// let label = new TextField();
// label.text = 'Hello CanvasWidget!';
// label.fillColor = '#000';
// label.size = 40;
// this.addChild(label);
this
.
drops
=
[];
this
.
stage
.
addEventListener
(
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
this
.
addDrops
();
}
addDrops
()
{
const
drop
=
new
DropItem
({
initialVelocityY
:
-
50
,
initialVelocityX
:
10
,
accelerationY
:
2
});
drop
.
y
=
1000
;
this
.
addChild
(
drop
);
this
.
drops
.
push
(
drop
);
}
this
.
addChild
(
new
Root
());
onEnterFrame
()
{
this
.
drops
.
forEach
(
i
=>
i
.
onEnterFrame
());
}
/**
...
...
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