Commit 8a3ba213 by Nick An

Merge branch 'develop' of cd.i.strikingly.com:shawn.wang/crazyflirt into develop

parents cd293d04 71d6bd0d
node_modules/
.wing/
fe_wxgame/
\ No newline at end of file
......@@ -3,7 +3,7 @@
"compilerVersion": "5.1.10",
"template": {},
"target": {
"current": "web"
"current": "wxgame"
},
"modules": [
{
......
......@@ -29,8 +29,6 @@
class Main extends egret.DisplayObjectContainer {
public constructor() {
super();
this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
......@@ -66,7 +64,6 @@ class Main extends egret.DisplayObjectContainer {
await this.loadResource()
this.createGameScene();
const result = await RES.getResAsync("description_json")
this.startAnimation(result);
await platform.login();
const userInfo = await platform.getUserInfo();
console.log(userInfo);
......@@ -86,104 +83,12 @@ class Main extends egret.DisplayObjectContainer {
}
}
private textfield: egret.TextField;
/**
* 创建游戏场景
* Create a game scene
*/
private createGameScene() {
let sky = this.createBitmapByName("bg_jpg");
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();
this.addChild(SceneManager.getInstance());
}
}
\ No newline at end of file
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
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
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
var gulp = require('gulp')
var run = require('gulp-run-command').default
gulp.task("build", run(["egret run ./fe"]));
gulp.task(`watch`, () => {
gulp.watch('./fe/**/**.*', [`build`])
})
{
"name": "fe",
"version": "1.0.0",
"description": "",
"main": "gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-run-command": "0.0.9",
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment