Commit 962fd5d9 authored by rockyl's avatar rockyl

提交一波

parent 12377187
{"id":"engine","url":"engine.53262d62b13fbd758c11074e8875d82b17828de5.js"}
\ No newline at end of file
......@@ -21,13 +21,13 @@
"typescript": "^2.7.2"
},
"scripts": {
"declare": "node scripts/declare.js",
"declare": "node scripts/declare.js src/index.ts",
"rollup": "rollup -c -o dist/engine.js",
"rollup:debug": "rollup -c -m ",
"rollup:prod": "rollup -c -o dist/engine.js --environment BUILD:production",
"rename": "node scripts/rename-hash.js dist/engine.js",
"build": "rm -rf dist&&yarn rollup:prod && yarn rename && ali-oss-publish -c oss.config.js -e dist",
"build:debug": "rm -rf dist&&yarn rollup && yarn rename && ali-oss-publish -c oss.config.js -e dist",
"preprocess": "node scripts/pre-process.js engine dist/engine.js",
"build": "rm -rf dist&&yarn rollup:prod && yarn preprocess && ali-oss-publish -c oss.config.js -e dist",
"build:debug": "rm -rf dist&&yarn rollup && yarn preprocess && ali-oss-publish -c oss.config.js -e dist",
"ts": "dts-bundle --name engine --main types/src/index.d.ts --out ../../dist/index.d.ts",
"test": "echo \"Error: no test specified\" && exit 1",
"mergeDts": "node scripts/mergeDts.js"
......
......@@ -4,20 +4,32 @@
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const fileName = process.argv[2];
const [_, __, id, fileName] = process.argv;
const stream = fs.createReadStream(fileName);
const fsHash = crypto.createHash('sha1');
stream.on('data', function(d) {
stream.on('data', function (d) {
fsHash.update(d);
});
stream.on('end', function() {
stream.on('end', function () {
const md5 = fsHash.digest('hex');
loadComplete(md5);
});
function loadComplete(md5) {
const extIndex = fileName.lastIndexOf('.');
const newFileName = fileName.substr(0, extIndex + 1) + md5 + fileName.substr(extIndex);
fs.renameSync(fileName, newFileName)
});
\ No newline at end of file
fs.renameSync(fileName, newFileName);
let manifest = {
id,
url: path.basename(newFileName),
};
fs.writeFileSync('manifest.json', JSON.stringify(manifest));
}
......@@ -446,6 +446,14 @@ export default class Container extends DisplayObject {
}
}
let widthSetted = !!this._width && this._width !== 0;
let heightSetted = !!this._height && this._height !== 0;
if(widthSetted){
this._bounds.width = this._width;
}
if(heightSetted){
this._bounds.height = this._height;
}
}
/**
......@@ -463,9 +471,9 @@ export default class Container extends DisplayObject {
//如果不可见
if (!this.visible) return null
//如果禁止子级的鼠标事件
if (isMouseEvent && !this.mouseChildren) return null;
if (isMouseEvent && !this.mouseChildren) return this.hitTestSelf(globalPoint);
var children = this.children;
var length = children.length
var length = children.length;
let child, hitDisplayObject;
//后序遍历,后添加的在上层
for (var i = length - 1; i >= 0; i--) {
......@@ -479,9 +487,29 @@ export default class Container extends DisplayObject {
//存在直接返回
if (hitDisplayObject) return hitDisplayObject;
}
return this.hitTestSelf(globalPoint);
}
hitTestSelf(globalPoint) {
if (this.mouseEnabled) {
return this.hitTestSelfBounds(globalPoint);
}
return null;
}
hitTestSelfBounds(globalPoint) {
if (this.width && this.height) {
let lp = this.globalToLocal(globalPoint, DisplayObject._bp);
if (lp.x > 0 &&
lp.x < this.width &&
lp.y > 0 &&
lp.y < this.height
) return this;
}
return null
}
/**
* webgl渲染
* @param {WebglRenderer} renderer - The renderer
......
......@@ -642,8 +642,8 @@ export class Stage extends Container {
} else {
cp = new Point();
}
cp.x = (points[o].clientX - points[o].target.offsetLeft) * devicePixelRatio;
cp.y = (points[o].clientY - points[o].target.offsetTop) * devicePixelRatio;
cp.x = (points[o].clientX - points[o].target.offsetLeft + window.pageXOffset) * devicePixelRatio;
cp.y = (points[o].clientY - points[o].target.offsetTop + window.pageYOffset) * devicePixelRatio;
//计算舞台中的点
sp = s.globalToLocal(cp, DisplayObject._bp);
//检查是否有鼠标事件
......
......@@ -3,6 +3,7 @@ import {TextureCache} from "../utils";
import {Texture} from "../texture";
import {httpRequest} from "../net";
import {createTextureSheet} from "../../zeroing/game-warpper/texture-sheet";
import {preloadSound} from "../../zeroing/game-warpper/sound";
export class Loader extends EventDispatcher {
......@@ -60,6 +61,12 @@ export class Loader extends EventDispatcher {
return this.loadRaw(url, uuid, 'text');
}
loadSound(url: string, uuid?: string) {
preloadSound(url, uuid);
return Promise.resolve();
}
loadImage(url: string, uuid?: string) {
return new Promise((resolve, reject) => {
let img = this.caches[uuid || url];
......
......@@ -46,9 +46,18 @@ export function httpRequest(url: string, method: string = 'get', params?: any, t
function doProxyRequest(payload, resolve, reject) {
let proxyWindow = window['proxy_window'];
window.addEventListener('message', function (event) {
window.addEventListener('message', onMessage, false);
proxyWindow.postMessage(JSON.stringify({
action: 'http-request-proxy',
payload: payload,
}), '*');
function onMessage(event) {
window.removeEventListener('message', onMessage);
try {
let data = JSON.parse(event.data);
console.log('onMessage', event.data);
switch (data.action) {
case 'http-request-proxy-resolve':
......@@ -61,12 +70,7 @@ function doProxyRequest(payload, resolve, reject) {
} catch (e) {
}
}, false);
proxyWindow.postMessage(JSON.stringify({
action: 'http-request-proxy',
payload: payload,
}), '*')
}
}
function doXhrRequest({url, method, params, type, headers}, resolve, reject) {
......@@ -82,18 +86,16 @@ function doXhrRequest({url, method, params, type, headers}, resolve, reject) {
const isGet = method.toUpperCase() === 'GET';
const queryStr = obj2query(params);
let openUrl = url;
/*if(openUrl.indexOf('projectx') >= 0){
openUrl = openUrl.replace(/projectx\/\w+\//, '');
}*/
if (openUrl.indexOf('projectx') == 0) {
openUrl = '/' + openUrl;
}
if (isGet) {
openUrl = urlJoin(openUrl, queryStr);
}
xhr.open(method, openUrl, true);
if (!isGet) {
for (let key in headers) {
xhr.setRequestHeader(key, headers[key]);
}
}
xhr.responseType = type;
xhr.onreadystatechange = () => {
if (xhr.readyState == 4 && xhr.status == 200) {
......@@ -118,7 +120,9 @@ function doXhrRequest({url, method, params, type, headers}, resolve, reject) {
function doRequest(payload, resolve, reject) {
if (window['proxy_window'] && payload.url.indexOf('blob') !== 0) {
doProxyRequest(payload, resolve, reject);
doProxyRequest(payload, function (p) {
resolve(p);
}, reject);
} else {
doXhrRequest(payload, resolve, reject);
}
......
......@@ -429,10 +429,10 @@ export default class Texture extends EventDispatcher {
if (texture.textureCacheIds.indexOf(id) === -1) {
texture.textureCacheIds.push(id);
}
if (TextureCache[id]) {
/*if (TextureCache[id]) {
//覆盖
console.warn(`Texture added to the cache with an id [${id}] that already had an entry`);
}
}*/
TextureCache[id] = texture;
}
}
......
......@@ -138,7 +138,7 @@ export class ScrollListBase extends ScrollViewBase {
if (s._isInit > 0) {
if (s._updateId != s.viewPort.transform._localID) {
const items = s._items;
let id: number = (Math.abs(Math.floor(Math.ceil(s.viewPort[s.paramXY]) / s._itemRow)) - 1) * s._cols;
let id: number = s.viewPort[s.paramXY] > 0 ? 0 : (Math.abs(Math.floor(s.viewPort[s.paramXY] / s._itemRow)) - 1) * s._cols;
id = id < 0 ? 0 : id;
if (id != s._lastFirstId) {
s._lastFirstId = id;
......
......@@ -203,7 +203,7 @@ export class ScrollViewBase extends Container {
s.addSpeed = 0;
s.speed = 0;
s.isStop = true;
view[s.paramXY] = s.distance - s.maxDistance;
view[s.paramXY] = Math.min(0, s.distance - s.maxDistance);
return;
}
}
......
......@@ -102,12 +102,13 @@ function putInCanvas(imagesAll, textures) {
var freeRects = [];
//图片信息数组
var imageInfos: imageInfo[] = [];
//先初始化4096*4096
var size = 2048;
//先初始化size*size
var canvas = document.createElement('canvas');
canvas.width = 4096;
canvas.height = 4096;
canvas.width = size;
canvas.height = size;
//添加第一个可用矩形
freeRects.push(new Rectangle(0, 0, 4096, 4096))
freeRects.push(new Rectangle(0, 0, size, size))
//可变
var canvasWidth = 0, canvasHeight = 0
//先排满在canvas
......@@ -117,10 +118,10 @@ function putInCanvas(imagesAll, textures) {
match = false
for (var j = freeRects.length - 1; j >= 0; j--) {
let freeRect = freeRects[j];
if (freeRect.width >= img.width + padding * 2 && freeRect.height >= img.height + padding * 2) {
if (freeRect.width >= img.width + padding && freeRect.height >= img.height + padding) {
match = true
//有满足的,记录
var imageIn = new imageInfo(img, freeRect.x + padding, freeRect.y + padding)
var imageIn = new imageInfo(img, freeRect.x, freeRect.y)
imageInfos.push(imageIn)
//imagesAll里移除
imagesAll.splice(i, 1);
......
......@@ -24,7 +24,7 @@ export * from "./2d/ui";
export * from './2d/tween'
export * from './2d/net'
export {GlobalPro, DrawAllToCanvas} from './2d/utils'
export * from './2d/utils'
export { default as toDisplayDataURL } from "./2d/utils/toDisplayDataURL";
......
......@@ -17,7 +17,7 @@ function logProcess(meta, vm, process, ...params) {
let showLog = false;
if (typeof logConfig === 'boolean') {
showLog = true;
showLog = logConfig;
} else if (logConfig.indexOf(meta.id) >= 0 || logConfig.indexOf(meta.name) >= 0) {
showLog = true;
}
......
......@@ -126,7 +126,7 @@ class ScriptsProxy {
* @param options
* @param disabled
*/
add(name, options, disabled): ScriptBase {
add(name, options, disabled = false): ScriptBase {
let def = scriptDefs[name];
if (!def) {
console.warn(`script[${name}] def not exists`);
......
......@@ -2,7 +2,7 @@
* Created by rockyl on 2019-11-05.
*/
import {Container, Stage} from "../../2d/display";
import {Container, Stage} from "../../2d/display/index";
import {StackContainer} from "./StackContainer";
import {loadAssets} from "./assets-manager";
import {instantiate} from "./view-interpreter";
......
/**
* Created by rockyl on 2019-11-22.
*/
const template = `
<div style="
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: flex;
display: -webkit-flex;
justify-content: center;
-webkit-justify-content: center;
align-items: center;
-webkit-align-items: center;
">
<img src="//yun.duiba.com.cn/editor/zeroing/assets/loading.gif">
</div>
`;
let container = document.createElement('div');
container.innerHTML = template;
let wrapper = container.removeChild(container.children[0]);
export default {
onProgress(done, total) {
if (!wrapper.parentElement) {
document.body.appendChild(wrapper);
}
},
onComplete() {
if (wrapper.parentElement) {
document.body.removeChild(wrapper);
}
},
}
......@@ -3,35 +3,88 @@
*/
const template = `
<div style="
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: flex;
display: -webkit-flex;
justify-content: center;
-webkit-justify-content: center;
align-items: center;
-webkit-align-items: center;
">
<img src="//yun.duiba.com.cn/editor/zeroing/assets/loading.gif"
<div class="zeroing-loading-wrapper">
<div class="zeroing-loading-content">
</div>
</div>
`;
let container = document.createElement('div');
container.innerHTML = template;
let wrapper = container.removeChild(container.children[0]);
const style = `
.zeroing-loading-wrapper{
position: absolute;
top:0;
left: 0;
right: 0;
bottom: 0;
display: flex;
display: -webkit-flex;
justify-content: center;
-webkit-justify-content: center;
align-items: center;
-webkit-align-items: center;
}
@keyframes part-body
{
0%,40% {transform: scale(1);}
20% {transform: scale(1.5);}
}
.zeroing-loading-part {
transform-origin: 2px 12px;
position: absolute;
}
.zeroing-loading-part-body{
background-color: dimgray;
width: 4px;
height: 6px;
border-radius: 2px;
transform-origin: 2px 6px;
animation: part-body 1500ms linear infinite;
}
`;
let inited = false;
let wrapper;
function init() {
if (inited) {
return;
}
inited = true;
let container = document.createElement('div');
container.innerHTML = template;
wrapper = container.removeChild(container.children[0]);
let styleEl = document.createElement('style');
styleEl.innerText = style;
document.body.appendChild(styleEl);
let content = wrapper.children[0];
let count = 8;
let perDelay = 1500 / count;
let perDeg = 360 / count;
for (let i = 0; i < count; i++) {
let part = document.createElement('div');
part.innerHTML = `<div class="zeroing-loading-part" style="
transform: rotate(${i * perDeg}deg); ">
<div class="zeroing-loading-part-body" style="
animation-delay:${-(count - i) * perDelay}ms;
"></div>
</div>`;
content.appendChild(part.children[0]);
}
}
export default {
onProgress(done, total) {
init();
if (!wrapper.parentElement) {
document.body.appendChild(wrapper);
}
},
onComplete() {
if (wrapper.parentElement) {
if (wrapper && wrapper.parentElement) {
document.body.removeChild(wrapper);
}
},
......
......@@ -2,7 +2,7 @@
* Created by rockyl on 2019-11-05.
*/
import {Container, DisplayObject} from "../../2d/display";
import {Container, DisplayObject} from "../../2d/display/index";
/**
* 栈式视图容器
......
......@@ -2,7 +2,7 @@
* Created by rockyl on 2019-11-25.
*/
import {Container} from "../../2d/display";
import {Container} from "../../2d/display/index";
import {GameStage} from "./GameStage";
import {Label, Rect} from "./nodes";
import {Tween} from "../../2d/tween";
......@@ -16,6 +16,7 @@ export class Toast extends Container {
constructor(gameStage: GameStage) {
super();
this._gameStage = gameStage;
this.mouseEnabled = this.mouseChildren = false;
this.horizonCenter = 0;
this.verticalCenter = 0;
......
......@@ -18,6 +18,7 @@ const loaderMapping = {
'.json': 'Json',
'.svga': 'Svga',
'.sht': 'Sheet',
'.mp3': 'Sound',
'': 'Raw',
};
......@@ -74,7 +75,21 @@ export function loadAssets(config, onProgress?, onComplete?) {
* @param uuid
*/
export function getAssetByUUID(uuid): any {
return arrayFind(assetsConfig, item => item.uuid === uuid);
let result = arrayFind(assetsConfig, item => item.uuid === uuid);
if (result) {
return result;
} else {
for (let assetConfig of assetsConfig) {
let res = globalLoader.get(assetConfig.url);
if (res && res.frames) {
for (let key in res.frames) {
if (key === uuid) {
return {uuid: key};
}
}
}
}
}
}
/**
......@@ -92,7 +107,7 @@ export function getAssetByName(name): any {
for (let key in res.frames) {
const frame = res.frames[key];
if (frame.name === name) {
return {url: key};
return {uuid: key};
}
}
}
......
......@@ -12,10 +12,17 @@ const customMap = {};
* @param customs
*/
export function registerCustomModules(customs) {
if(!customs){
return;
}
for (let custom of customs) {
if(custom.assets){
customMap[custom.id].assets = custom.assets;
}
if(custom.props){
customMap[custom.id].props = custom.props;
}
}
}
/**
......
......@@ -7,7 +7,7 @@ import Sprite from "../../../2d/display/Sprite";
import Texture from "../../../2d/texture/Texture";
import {getFont} from "../bmp-text-manager";
import {dirtyFieldTrigger} from "../../decorators";
import {VERTICAL_ALIGN} from "../../..";
import {VERTICAL_ALIGN} from "../../../2d/const";
export class BitmapText extends Container {
private _charCache = [];
......@@ -52,6 +52,12 @@ export class BitmapText extends Container {
maxHeight = sp.height;
}
}
for (let j = li, lj = this.children.length; j < lj; j++) {
this._charCache.push(this.removeChildAt(j));
j--;
lj--;
}
if (this._height) {
maxHeight = this._height;
}
......@@ -69,9 +75,6 @@ export class BitmapText extends Container {
break;
}
}
for (let i = li; i < this.children.length; i++) {
this._charCache.push(this.removeChildAt(li));
}
}
private addChar(char, index) {
......
......@@ -2,7 +2,7 @@
* Created by rockyl on 2020-01-07.
*/
import {FloatDisplay} from "../../../2d/display";
import {FloatDisplay} from "../../../2d/display/index";
import {afterConstructor} from "../../decorators/after-constructor";
import {applyAutoAdjust} from "../../decorators/auto-adjust";
import {applyScript} from "../../decorators/scripts";
......
......@@ -42,7 +42,7 @@ export class Image extends Sprite {
} else { //否则就使用素材名
const assetConfig = getAssetByName(url);
if (assetConfig) {
url = assetConfig.url;
url = assetConfig.uuid;
}
}
this.texture = Texture.fromImage(url);
......
/**
* Created by rockyl on 2019-11-08.
*/
import {TextField} from "../../../2d/text";
import {TextField} from "../../../2d/text/index";
import {dataCenter} from "../data-center";
import {ESCAPE_REG_EXP, htmlToPureText} from "../../utils";
import {Event} from "../../../2d/events";
/**
* 文本
......
......@@ -5,10 +5,26 @@ import {Label} from "./Label";
import {MouseEvent} from "../../../2d/events/MouseEvent";
import {Event} from "../../../2d/events/Event";
import {FloatDisplay} from "../../../2d/display/FloatDisplay";
import {TextField} from "../../../2d/text";
import {Point} from "../../../2d/math";
import {TextField} from "../../../2d/text/index";
import {Point} from "../../../2d/math/index";
import {dirtyFieldTrigger} from "../../decorators";
import {VERTICAL_ALIGN} from "../../..";
import {VERTICAL_ALIGN} from "../../../2d/const";
let timer;
function delayScrollTop() {
cancelDelayScrollTop();
timer = setTimeout(function () {
window.scrollTo(0, 0);
}, 100);
}
function cancelDelayScrollTop() {
if (timer) {
clearTimeout(timer);
timer = null;
}
}
export class TextInput extends Label {
private _floatDisplay: FloatDisplay;
......@@ -23,10 +39,11 @@ export class TextInput extends Label {
@dirtyFieldTrigger
type: string = 'text';
@dirtyFieldTrigger
pattern: string;
charRegStr: string;
private _oldFillColor;
private _oldStrokeColor;
private _charReg: RegExp;
constructor() {
super();
......@@ -51,7 +68,10 @@ export class TextInput extends Label {
}
break;
case 'maxLength':
this.setMaxLength();
this._text = this.updateMaxLength(this._text);
break;
case 'charRegStr':
this.setCharReg();
break;
}
}
......@@ -70,12 +90,12 @@ export class TextInput extends Label {
style.backgroundColor = 'transparent';
input.type = 'text';
input.addEventListener('focus', this.onFocus);
input.addEventListener('blur', this.onBlur);
input.addEventListener('input', this.onInput);
let pl = this._placeholderLabel = new TextField();
pl.fillColor = this.placeholderColor;
this.verticalAlign = pl.verticalAlign = VERTICAL_ALIGN.MIDDLE;
this.addChild(fd);
......@@ -84,18 +104,42 @@ export class TextInput extends Label {
protected _setText(value) {
super._setText(value);
this.setMaxLength();
this._text = this.updateMaxLength(this._text);
this._text = this.updateWithCharReg(this._text);
setTimeout(() => {
this.showPlaceholderLabel(value)
}, 1);
}
private setMaxLength() {
let value = this._text;
private updateMaxLength(text) {
let value = text;
let maxLength = this.maxLength;
if (maxLength > 0 && value && value.length > maxLength) {
this.text = value.substr(0, maxLength);
value = value.substr(0, maxLength);
}
return value;
}
private updateWithCharReg(text) {
let value = text;
if (this._charReg) {
value = '';
for (let char of text) {
if (char.match(this._charReg)) {
value += char;
}
}
}
return value;
}
private setCharReg() {
if (this.charRegStr) {
this._charReg = new RegExp(this.charRegStr);
this._text = this.updateWithCharReg(this._text);
} else {
this._charReg = null;
}
}
......@@ -113,6 +157,7 @@ export class TextInput extends Label {
pl.font = this.font;
this.addChildAt(pl, 0);
}
pl.textAlign = this.textAlign;
}
}
......@@ -131,6 +176,8 @@ export class TextInput extends Label {
style.width = this.width + 'px';
style.height = this.height + 'px';
style.fontFamily = this.font;
style.pointerEvents = 'auto';
style.textAlign = this.textAlign;
this._oldFillColor = this.fillColor;
this._oldStrokeColor = this.strokeColor;
......@@ -140,10 +187,10 @@ export class TextInput extends Label {
if (pl.parent) {
pl.parent.removeChild(pl);
}
//this.addChild(this._floatDisplay);
this._floatDisplay.alpha = 1;
input.style.pointerEvents = 'auto';
const maxLength = this.maxLength;
if (maxLength > 0) {
......@@ -152,12 +199,6 @@ export class TextInput extends Label {
input.removeAttribute('maxLength')
}
if (this.pattern) {
input.pattern = this.pattern;
} else {
input.removeAttribute('pattern')
}
if (this.type) {
input.type = this.type;
}
......@@ -183,18 +224,32 @@ export class TextInput extends Label {
this.dispatchEvent(Event.BLUR);
}
private onFocus = (e) => {
cancelDelayScrollTop();
};
private onBlur = (e) => {
this.setBlur();
delayScrollTop();
};
private onInput = (e) => {
if (this._charReg) {
//console.log('before:', this._input.value);
let text = this.updateWithCharReg(this._input.value);
//console.log('after:', text);
this._input.value = text;
}
this.dispatchEvent(Event.CHANGING, this._input.value);
};
private onClickStage(e) {
if (e.currentTarget !== this) {
//e.stopPropagation();
//if (e.currentTarget !== this) {
this.setBlur();
}
//}
}
private onClickStatic() {
......
......@@ -61,3 +61,19 @@ export function stopSound(name) {
export function destroySound(name) {
delete instances[name];
}
export function mute(muted = true) {
Howler.mute(muted)
}
export function preloadSound(url, uuid) {
let sound = new Howl({
src: url,
preload: true,
});
instances[uuid] = {
sound,
keep: true,
};
}
......@@ -2,9 +2,9 @@
* Created by rockyl on 2019-11-08.
*/
import {Container} from "../../2d/display";
import {Container} from "../../2d/display/index";
import {Rect, Image, Label, Circle, ScrollView, TextInput, ScrollList, BitmapText, HtmlView} from "./nodes";
import {injectProperties, instantiateScript,} from "../utils";
import {injectProperties, instantiateScript,} from "../utils/index";
const nodeTypeMapping = {
node: Container,
......
......@@ -15,6 +15,7 @@ import {instantiate, registerNodeType} from './game-warpper/view-interpreter'
export {Howl, Howler} from 'howler';
import emojiRegex from 'emoji-regex';
export {compute as computeProps} from 'props-compute';
const emojiRegexp = emojiRegex();
......
......@@ -14,7 +14,7 @@ import {queryParams} from "./web";
export let gameStage: GameStage;
export function launch(url, loadingDelegate?, onStart?) {
if(queryParams.__proxy_mode__){
if (queryParams.__proxy_mode__) {
return Promise.resolve('cancel launch');
}
return globalLoader.loadJson(url)
......@@ -45,8 +45,11 @@ export function launchWithWindowVariable(name, loadingDelegate?, onStart?) {
return launchWithConfig(data, loadingDelegate, onStart);
}
export function launchWithConfig(config, loadingDelegate?, onStart?) {
return new Promise(resolve => {
export async function launchWithConfig(config, loadingDelegate?, onStart?) {
await new Promise(resolve => {
setTimeout(resolve, 300);
});
return await new Promise(resolve => {
const {containerId, designWidth, designHeight, frameRate, scaleMode, rendererType,} = config.options;
let stage = window['stage'] = new Stage(
containerId || "game-container",
......@@ -67,9 +70,9 @@ export function launchWithConfig(config, loadingDelegate?, onStart?) {
let delegate = loadingDelegate || builtinLoadingView;
gameStage.launch(config, function(done, total){
gameStage.launch(config, function (done, total) {
delegate.onProgress && delegate.onProgress(done, total)
}, function(){
}, function () {
delegate.onComplete && delegate.onComplete();
}, onStart);
});
......
......@@ -3,5 +3,6 @@
*/
export * from './utils'
export * from './math'
export * from './md5'
export * from './ObjectPool'
/**
* Created by rockyl on 2020-01-21.
*/
export function transPoint(str, sep = ',') {
if (str) {
let arr = str.split(sep);
return {
x: parseFloat(arr[0]),
y: parseFloat(arr[1] === undefined ? '0' : arr[1]),
}
}
}
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