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
ecdc964e
Commit
ecdc964e
authored
Jan 18, 2021
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
36f8b2d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
23 deletions
+43
-23
GameStage.ts
src/GameStage.ts
+0
-19
App.js
test/src/App.js
+4
-4
main.js
test/src/game/main.js
+39
-0
No files found.
src/GameStage.ts
View file @
ecdc964e
/**
* Created by rockyl on 2020/11/14.
* 一个简单示例
*/
import
{
WidgetBase
,
TextField
,
Sprite
,
TextureCache
,
Tween
}
from
"spark-wrapper-fyge"
;
import
{
WidgetBase
,
TextField
,
Sprite
,
TextureCache
,
Tween
}
from
"spark-wrapper-fyge"
;
export
class
GameStage
extends
WidgetBase
{
export
class
GameStage
extends
WidgetBase
{
...
@@ -13,19 +9,4 @@ export class GameStage extends WidgetBase {
...
@@ -13,19 +9,4 @@ export class GameStage extends WidgetBase {
label
.
size
=
40
;
label
.
size
=
40
;
this
.
addChild
(
label
);
this
.
addChild
(
label
);
}
}
/**
* 销毁回调
*/
onDestroy
()
{
}
start
()
{
}
stop
()
{
}
}
}
test/src/App.js
View file @
ecdc964e
import
React
,
{
useState
,
useRef
}
from
'react'
;
import
React
,
{
useState
,
useRef
}
from
'react'
;
import
'./App.scss'
;
import
'./App.scss'
;
import
{
CanvasWidget
}
from
'@spark/ui'
;
import
{
CanvasWidget
}
from
'@spark/ui'
;
import
{
Playground
}
from
"./
bundle
"
;
import
{
Playground
}
from
"./
game/main.js
"
;
/**
/**
* 配置覆盖
* 配置覆盖
...
@@ -21,7 +21,7 @@ const widgetConfig = {
...
@@ -21,7 +21,7 @@ const widgetConfig = {
}
}
function
App
()
{
function
App
()
{
const
[
widgetVisible
,
setWidgetVisible
]
=
useState
(
fals
e
);
const
[
widgetVisible
,
setWidgetVisible
]
=
useState
(
tru
e
);
const
widgetRef
=
useRef
();
const
widgetRef
=
useRef
();
function
onReady
(
widget
)
{
function
onReady
(
widget
)
{
...
@@ -59,13 +59,13 @@ function App() {
...
@@ -59,13 +59,13 @@ function App() {
return
(
return
(
<
div
className
=
"App"
>
<
div
className
=
"App"
>
<
div
className
=
"control-bar"
>
{
/*
<div className="control-bar">
<button onClick={e => onClickButton('setup')}>setup</button>
<button onClick={e => onClickButton('setup')}>setup</button>
<button onClick={e => onClickButton('unSetup')}>unSetup</button>
<button onClick={e => onClickButton('unSetup')}>unSetup</button>
<button onClick={e => onClickButton('start')}>start</button>
<button onClick={e => onClickButton('start')}>start</button>
<button onClick={e => onClickButton('stop')}>stop</button>
<button onClick={e => onClickButton('stop')}>stop</button>
<
/div
>
</div>
*/
}
{
{
widgetVisible
?
<
CanvasWidget
ref
=
{
widgetRef
}
className
=
"canvas-widget"
widgetFactory
=
{
Playground
}
widgetConfig
=
{
widgetConfig
}
widgetVisible
?
<
CanvasWidget
ref
=
{
widgetRef
}
className
=
"canvas-widget"
widgetFactory
=
{
Playground
}
widgetConfig
=
{
widgetConfig
}
onEvent
=
{
onEvent
}
onEvent
=
{
onEvent
}
...
...
test/src/game/main.js
0 → 100644
View file @
ecdc964e
import
{
WidgetBase
,
TextField
}
from
'spark-wrapper-fyge'
;
import
metaConfig
from
'../meta.json'
;
class
GameStage
extends
WidgetBase
{
onLaunched
()
{
let
label
=
new
TextField
();
label
.
text
=
'Hello CanvasWidget!'
;
label
.
fillColor
=
'#000'
;
label
.
size
=
40
;
this
.
addChild
(
label
);
}
/**
* 销毁回调
*/
onDestroy
()
{
}
start
()
{
}
stop
()
{
}
}
/**
* Created by rockyl on 2020/9/19.
*/
/**
* Playground模块
* @description Playground模块的工厂方法
* @ctype CANVAS_WIDGET
*/
function
Playground
()
{
return
new
GameStage
(
getMetaConfig
(
'Playground'
));
}
function
getMetaConfig
(
id
){
return
metaConfig
[
id
]
}
//===== END APPEND CODE =====
export
{
Playground
};
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