Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
crazyflirt
Project
Overview
Details
Activity
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
Shawn Wang
crazyflirt
Commits
71d6bd0d
Commit
71d6bd0d
authored
May 05, 2018
by
Matt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add scenes
parent
d31a6fe1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
97 deletions
+75
-97
Main.ts
fe/src/Main.ts
+1
-97
SceneManager.ts
fe/src/SceneManager.ts
+39
-0
GameScene.ts
fe/src/scenes/GameScene.ts
+17
-0
RoomScene.ts
fe/src/scenes/RoomScene.ts
+18
-0
No files found.
fe/src/Main.ts
View file @
71d6bd0d
...
@@ -29,8 +29,6 @@
...
@@ -29,8 +29,6 @@
class
Main
extends
egret
.
DisplayObjectContainer
{
class
Main
extends
egret
.
DisplayObjectContainer
{
public
constructor
()
{
public
constructor
()
{
super
();
super
();
this
.
addEventListener
(
egret
.
Event
.
ADDED_TO_STAGE
,
this
.
onAddToStage
,
this
);
this
.
addEventListener
(
egret
.
Event
.
ADDED_TO_STAGE
,
this
.
onAddToStage
,
this
);
...
@@ -66,7 +64,6 @@ class Main extends egret.DisplayObjectContainer {
...
@@ -66,7 +64,6 @@ class Main extends egret.DisplayObjectContainer {
await
this
.
loadResource
()
await
this
.
loadResource
()
this
.
createGameScene
();
this
.
createGameScene
();
const
result
=
await
RES
.
getResAsync
(
"description_json"
)
const
result
=
await
RES
.
getResAsync
(
"description_json"
)
this
.
startAnimation
(
result
);
await
platform
.
login
();
await
platform
.
login
();
const
userInfo
=
await
platform
.
getUserInfo
();
const
userInfo
=
await
platform
.
getUserInfo
();
console
.
log
(
userInfo
);
console
.
log
(
userInfo
);
...
@@ -86,104 +83,12 @@ class Main extends egret.DisplayObjectContainer {
...
@@ -86,104 +83,12 @@ class Main extends egret.DisplayObjectContainer {
}
}
}
}
private
textfield
:
egret
.
TextField
;
/**
/**
* 创建游戏场景
* 创建游戏场景
* Create a game scene
* Create a game scene
*/
*/
private
createGameScene
()
{
private
createGameScene
()
{
let
sky
=
this
.
createBitmapByName
(
"bg_jpg"
);
this
.
addChild
(
SceneManager
.
getInstance
());
this
.
addChild
(
sky
);
let
stageW
=
this
.
stage
.
stageWidth
;
let
stageH
=
this
.
stage
.
stageHeight
;
sky
.
width
=
stageW
;
sky
.
height
=
stageH
;
let
topMask
=
new
egret
.
Shape
();
topMask
.
graphics
.
beginFill
(
0x000000
,
0.5
);
topMask
.
graphics
.
drawRect
(
0
,
0
,
stageW
,
172
);
topMask
.
graphics
.
endFill
();
topMask
.
y
=
33
;
this
.
addChild
(
topMask
);
let
icon
=
this
.
createBitmapByName
(
"egret_icon_png"
);
this
.
addChild
(
icon
);
icon
.
x
=
26
;
icon
.
y
=
33
;
let
line
=
new
egret
.
Shape
();
line
.
graphics
.
lineStyle
(
2
,
0xffffff
);
line
.
graphics
.
moveTo
(
0
,
0
);
line
.
graphics
.
lineTo
(
0
,
117
);
line
.
graphics
.
endFill
();
line
.
x
=
172
;
line
.
y
=
61
;
this
.
addChild
(
line
);
let
colorLabel
=
new
egret
.
TextField
();
colorLabel
.
textColor
=
0xffffff
;
colorLabel
.
width
=
stageW
-
172
;
colorLabel
.
textAlign
=
"center"
;
colorLabel
.
text
=
"Hello Egret"
;
colorLabel
.
size
=
24
;
colorLabel
.
x
=
172
;
colorLabel
.
y
=
80
;
this
.
addChild
(
colorLabel
);
let
textfield
=
new
egret
.
TextField
();
this
.
addChild
(
textfield
);
textfield
.
alpha
=
0
;
textfield
.
width
=
stageW
-
172
;
textfield
.
textAlign
=
egret
.
HorizontalAlign
.
CENTER
;
textfield
.
size
=
24
;
textfield
.
textColor
=
0xffffff
;
textfield
.
x
=
172
;
textfield
.
y
=
135
;
this
.
textfield
=
textfield
;
}
}
/**
* 根据name关键字创建一个Bitmap对象。name属性请参考resources/resource.json配置文件的内容。
* Create a Bitmap object according to name keyword.As for the property of name please refer to the configuration file of resources/resource.json.
*/
private
createBitmapByName
(
name
:
string
)
{
let
result
=
new
egret
.
Bitmap
();
let
texture
:
egret
.
Texture
=
RES
.
getRes
(
name
);
result
.
texture
=
texture
;
return
result
;
}
/**
* 描述文件加载成功,开始播放动画
* Description file loading is successful, start to play the animation
*/
private
startAnimation
(
result
:
string
[])
{
let
parser
=
new
egret
.
HtmlTextParser
();
let
textflowArr
=
result
.
map
(
text
=>
parser
.
parse
(
text
));
let
textfield
=
this
.
textfield
;
let
count
=
-
1
;
let
change
=
()
=>
{
count
++
;
if
(
count
>=
textflowArr
.
length
)
{
count
=
0
;
}
let
textFlow
=
textflowArr
[
count
];
// 切换描述内容
// Switch to described content
textfield
.
textFlow
=
textFlow
;
let
tw
=
egret
.
Tween
.
get
(
textfield
);
tw
.
to
({
"alpha"
:
1
},
200
);
tw
.
wait
(
2000
);
tw
.
to
({
"alpha"
:
0
},
200
);
tw
.
call
(
change
,
this
);
};
change
();
}
}
}
\ No newline at end of file
fe/src/SceneManager.ts
0 → 100644
View file @
71d6bd0d
class
SceneManager
extends
egret
.
DisplayObjectContainer
{
// 场景控制器的单例
private
static
instance
:
SceneManager
;
// 开始场景
private
roomScene
:
RoomScene
;
// 游戏场景
private
gameScene
:
GameScene
;
public
constructor
()
{
super
();
this
.
init
();
}
private
init
()
{
// 实例化两个场景
this
.
roomScene
=
new
RoomScene
();
this
.
gameScene
=
new
GameScene
();
// 默认添加开始场景
this
.
addChild
(
this
.
roomScene
);
}
// 实例化单例获取方法
public
static
getInstance
():
SceneManager
{
if
(
!
SceneManager
.
instance
)
{
SceneManager
.
instance
=
new
SceneManager
();
}
return
SceneManager
.
instance
;
}
// 切换场景
public
changeScene
(
type
)
{
// 释放资源
if
(
this
[
type
]
&&
typeof
this
[
type
].
release
===
'function'
)
{
this
[
type
].
release
()
}
// 移除所有显示列表中的对象
this
.
removeChildren
();
// 添加下一个场景
this
.
addChild
(
this
[
type
]);
}
}
\ No newline at end of file
fe/src/scenes/GameScene.ts
0 → 100644
View file @
71d6bd0d
class
GameScene
extends
egret
.
Sprite
{
public
constructor
()
{
super
();
this
.
init
()
}
// 初始化(给开始按钮绑定点击事件)
private
init
()
{
// put display object to this scene
}
public
release
()
{
// 移除事件
}
}
\ No newline at end of file
fe/src/scenes/RoomScene.ts
0 → 100644
View file @
71d6bd0d
class
RoomScene
extends
egret
.
Sprite
{
public
constructor
()
{
super
();
this
.
init
()
}
// 初始化(给开始按钮绑定点击事件)
private
init
()
{
console
.
log
(
'RoomScene.init'
)
// put display object to this scene
}
public
release
()
{
// 移除事件
}
}
\ No newline at end of file
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