Commit 600d7f46 authored by wjf's avatar wjf

l

parent b96bf6ce
This diff is collapsed.
This diff is collapsed.
import {DisplayObject} from './DisplayObject'; import { DisplayObject } from './DisplayObject';
import {Rectangle} from "../math/Rectangle"; import { Rectangle } from "../math/Rectangle";
import {Point} from '../math'; import { Point } from '../math';
import CanvasRenderer from '../renderers/CanvasRenderer'; import CanvasRenderer from '../renderers/CanvasRenderer';
import {Event} from "../events/Event" import { Event } from "../events/Event"
import {WebglRenderer} from '../renderers/WebglRenderer'; import { WebglRenderer } from '../renderers/WebglRenderer';
import {applyAutoAdjust} from "../../zeroing/auto-adjust"; import { applyAutoAdjust } from "../../zeroing/auto-adjust";
/** /**
* 容器类 * 容器类
...@@ -490,15 +490,15 @@ export default class Container extends DisplayObject { ...@@ -490,15 +490,15 @@ export default class Container extends DisplayObject {
/** /**
* 更新方法 * 更新方法
*/ */
update() { update(deltaTime: number) {
if (!this.visible) return; if (!this.visible) return;
//更新自己的 //更新自己的
super.update() super.update(deltaTime)
//更新儿子们的 //更新儿子们的
let len = this.children.length; let len = this.children.length;
for (let i = len - 1; i >= 0; i--) { for (let i = len - 1; i >= 0; i--) {
const child = this.children[i]; const child = this.children[i];
if (child.visible) child.update(); if (child.visible) child.update(deltaTime);
} }
} }
......
import {EventDispatcher} from '../events/EventDispatcher'; import { EventDispatcher } from '../events/EventDispatcher';
import Transform from '../math/Transform'; import Transform from '../math/Transform';
import {Rectangle} from '../math/Rectangle'; import { Rectangle } from '../math/Rectangle';
import {Point} from "../math/Point"; import { Point } from "../math/Point";
import {Event} from "../events/Event"; import { Event } from "../events/Event";
import {Component} from '../component/Component'; import { Component } from '../component/Component';
import Graphics from '../graphics/Graphics'; import Graphics from '../graphics/Graphics';
import {DEG_TO_RAD, RAD_TO_DEG} from '../const'; import { DEG_TO_RAD, RAD_TO_DEG } from '../const';
/** /**
* 基础显示对象抽象类 * 基础显示对象抽象类
...@@ -611,7 +611,7 @@ export class DisplayObject extends EventDispatcher { ...@@ -611,7 +611,7 @@ export class DisplayObject extends EventDispatcher {
/** /**
* 更新方法,帧循环的监听事件放在这 * 更新方法,帧循环的监听事件放在这
*/ */
public update() { public update(deltaTime: number) {
//更新组件方法 //更新组件方法
for (var i = 0; i < this._components.length; i++) { for (var i = 0; i < this._components.length; i++) {
if (this._components[i].enabled) { if (this._components[i].enabled) {
...@@ -620,7 +620,7 @@ export class DisplayObject extends EventDispatcher { ...@@ -620,7 +620,7 @@ export class DisplayObject extends EventDispatcher {
} }
//监听的 //监听的
if (this.hasEventListener(Event.ENTER_FRAME)) { if (this.hasEventListener(Event.ENTER_FRAME)) {
this.dispatchEvent(Event.ENTER_FRAME); this.dispatchEvent(Event.ENTER_FRAME, deltaTime);
} }
} }
//组件相关方法,添加移除等 //组件相关方法,添加移除等
......
import Container from "./Container"; import Container from "./Container";
import {devicePixelRatio, osType, RENDERER_TYPE, StageScaleMode} from "../const" import { devicePixelRatio, osType, RENDERER_TYPE, StageScaleMode } from "../const"
import SystemRenderer from "../renderers/SystemRenderer"; import SystemRenderer from "../renderers/SystemRenderer";
import {Point, Rectangle} from "../math"; import { Point, Rectangle } from "../math";
import {EventDispatcher} from "../events/EventDispatcher"; import { EventDispatcher } from "../events/EventDispatcher";
import {Event} from "../events/Event"; import { Event } from "../events/Event";
import {FloatDisplay} from "./FloatDisplay"; import { FloatDisplay } from "./FloatDisplay";
import {DisplayObject} from "./DisplayObject"; import { DisplayObject } from "./DisplayObject";
import {MouseEvent} from "../events/MouseEvent"; import { MouseEvent } from "../events/MouseEvent";
import {WebglRenderer} from "../renderers/WebglRenderer"; import { WebglRenderer } from "../renderers/WebglRenderer";
import {GDispatcher} from "../events/GDispatcher"; import { GDispatcher } from "../events/GDispatcher";
import CanvasRenderer from "../renderers/CanvasRenderer"; import CanvasRenderer from "../renderers/CanvasRenderer";
import {GlobalPro, isWebGLSupported} from "../utils"; import { GlobalPro, isWebGLSupported } from "../utils";
//如果以后还出现帧率问题,使用ticker; //如果以后还出现帧率问题,使用ticker;
//兼容requestAnimationFrame //兼容requestAnimationFrame
...@@ -131,7 +131,7 @@ export class Stage extends Container { ...@@ -131,7 +131,7 @@ export class Stage extends Container {
this._pause = value; this._pause = value;
if (value != this._pause) { if (value != this._pause) {
//触发事件 //触发事件
GDispatcher.dispatchEvent("onStagePause", {pause: value}); GDispatcher.dispatchEvent("onStagePause", { pause: value });
} }
} }
...@@ -574,7 +574,7 @@ export class Stage extends Container { ...@@ -574,7 +574,7 @@ export class Stage extends Container {
vH *= ih / 100; vH *= ih / 100;
} }
} }
return {w: vW, h: vH}; return { w: vW, h: vH };
} }
/** /**
...@@ -946,6 +946,9 @@ export class Stage extends Container { ...@@ -946,6 +946,9 @@ export class Stage extends Container {
* @method flushAll * @method flushAll
*/ */
static flushAll(): void { static flushAll(): void {
//记录起始时间
if (!GlobalPro.startTime) GlobalPro.startTime = Date.now();
if (!Stage._pause) { if (!Stage._pause) {
let len = Stage.allUpdateObjList.length; let len = Stage.allUpdateObjList.length;
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
......
...@@ -99,6 +99,7 @@ export class Loader extends EventDispatcher { ...@@ -99,6 +99,7 @@ export class Loader extends EventDispatcher {
callback(false, e); callback(false, e);
}; };
img.src = url; img.src = url;
return img
} }
loadSvga(callback: (suc: boolean, data: VideoEntity) => void, url: string) { loadSvga(callback: (suc: boolean, data: VideoEntity) => void, url: string) {
...@@ -133,4 +134,6 @@ async function fetchAsync(url: string) { ...@@ -133,4 +134,6 @@ async function fetchAsync(url: string) {
// fetchAsync("") // fetchAsync("")
// .then(data => console.log(data)) // .then(data => console.log(data))
// .catch(reason => console.log(reason.message)) // .catch(reason => console.log(reason.message))
\ No newline at end of file
export const globalLoader = new Loader();
\ No newline at end of file
...@@ -8,6 +8,7 @@ import {Matrix} from '../math'; ...@@ -8,6 +8,7 @@ import {Matrix} from '../math';
import {DisplayObject} from '../display/DisplayObject'; import {DisplayObject} from '../display/DisplayObject';
import CanvasSpriteRenderer from './plugins/CanvasSpriteRenderer'; import CanvasSpriteRenderer from './plugins/CanvasSpriteRenderer';
import {CanvasGraphicsRenderer} from './plugins/CanvasGraphicsRenderer'; import {CanvasGraphicsRenderer} from './plugins/CanvasGraphicsRenderer';
import { GlobalPro } from '../utils';
/** /**
...@@ -113,7 +114,7 @@ export default class CanvasRenderer extends SystemRenderer { ...@@ -113,7 +114,7 @@ export default class CanvasRenderer extends SystemRenderer {
} }
//update更新属性 //update更新属性
displayObject.update() displayObject.update(Date.now() - GlobalPro.startTime)
//存下真实的父级对象 //存下真实的父级对象
const cacheParent = displayObject.parent; const cacheParent = displayObject.parent;
......
import BatchRenderer from "./plugins/BatchRenderer"; import BatchRenderer from "./plugins/BatchRenderer";
import SystemRenderer from "./SystemRenderer"; import SystemRenderer from "./SystemRenderer";
import {RendererOptions} from "./RendererOptions"; import { RendererOptions } from "./RendererOptions";
import {devicePixelRatio, RENDERER_TYPE, SCALE_MODES} from "../const"; import { devicePixelRatio, RENDERER_TYPE, SCALE_MODES } from "../const";
import {createContext, GLShader, VertexArrayObject} from "../../glCore"; import { createContext, GLShader, VertexArrayObject } from "../../glCore";
import RenderTarget from "./renderTarget/RenderTarget"; import RenderTarget from "./renderTarget/RenderTarget";
import TextureManager from "./managers/TextureManager"; import TextureManager from "./managers/TextureManager";
import TextureGarbageCollector from "./managers/TextureGarbageCollector"; import TextureGarbageCollector from "./managers/TextureGarbageCollector";
import RenderTexture from "../texture/RenderTexture"; import RenderTexture from "../texture/RenderTexture";
import {Matrix} from "../math"; import { Matrix } from "../math";
import WebGLState from "./webgl/WebGLState"; import WebGLState from "./webgl/WebGLState";
import BatchManager from "./managers/BatchManager"; import BatchManager from "./managers/BatchManager";
import MaskManager from "./managers/MaskManager"; import MaskManager from "./managers/MaskManager";
import StencilManager from "./managers/StencilManager"; import StencilManager from "./managers/StencilManager";
import {DisplayObject} from "../display/DisplayObject"; import { DisplayObject } from "../display/DisplayObject";
import { GlobalPro } from "../utils";
let CONTEXT_UID = 0; let CONTEXT_UID = 0;
...@@ -170,7 +171,7 @@ export class WebglRenderer extends SystemRenderer { ...@@ -170,7 +171,7 @@ export class WebglRenderer extends SystemRenderer {
} }
//update更新属性 //update更新属性
displayObject.update() displayObject.update(Date.now() - GlobalPro.startTime)
//更新矩阵 //更新矩阵
const cacheParent = displayObject.parent; const cacheParent = displayObject.parent;
......
import Container from "../display/Container"; import Container from "../display/Container";
import {VideoEntity} from "./VideoEntity"; import { VideoEntity } from "./VideoEntity";
import Texture from "../texture/Texture"; import Texture from "../texture/Texture";
import Sprite from "../display/Sprite"; import Sprite from "../display/Sprite";
import {Event} from "../events/Event"; import { Event } from "../events/Event";
import {GlobalPro, TextureCache} from "../utils"; import { GlobalPro, TextureCache } from "../utils";
import {RAD_TO_DEG, RENDERER_TYPE} from "../const"; import { RAD_TO_DEG, RENDERER_TYPE } from "../const";
import {DrawAllToCanvas} from "../utils/DrawAllToCanvas"; import { DrawAllToCanvas } from "../utils/DrawAllToCanvas";
import {Button} from "../ui/Button"; import { Button } from "../ui/Button";
import {TextField} from "../text/TextField"; import { TextField } from "../text/TextField";
import {Matrix} from "../math"; import { Matrix } from "../math";
/** /**
* 用于播放动画 * 用于播放动画
...@@ -721,11 +721,11 @@ export class MovieClip extends Container { ...@@ -721,11 +721,11 @@ export class MovieClip extends Container {
* @public * @public
* @since 1.0.0 * @since 1.0.0
*/ */
public update(): void { public update(deltaTime: number): void {
let s: any = this; let s: any = this;
//更新帧数据 //更新帧数据
this.updateFrame(); this.updateFrame();
super.update(); super.update(deltaTime);
} }
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
* 记录的一些方法和设置 * 记录的一些方法和设置
*/ */
import {BLEND_MODES, DATA_URI, RENDERER_TYPE, URL_FILE_EXTENSION} from "../const" import { BLEND_MODES, DATA_URI, RENDERER_TYPE, URL_FILE_EXTENSION } from "../const"
export * from './twiddle'; export * from './twiddle';
export {default as toDisplayDataURL} from "./toDisplayDataURL"; export { default as toDisplayDataURL } from "./toDisplayDataURL";
export {default as determineCrossOrigin} from './determineCrossOrigin'; export { default as determineCrossOrigin } from './determineCrossOrigin';
let nextUid = 0; let nextUid = 0;
...@@ -309,7 +309,10 @@ export const GlobalPro = { ...@@ -309,7 +309,10 @@ export const GlobalPro = {
* 图集间隙 * 图集间隙
*/ */
padding: 2, padding: 2,
/**
* 时钟起始时间
*/
startTime: 0
} }
...@@ -319,7 +322,7 @@ export const GlobalPro = { ...@@ -319,7 +322,7 @@ export const GlobalPro = {
* @return {boolean} is webgl supported * @return {boolean} is webgl supported
*/ */
export function isWebGLSupported(): boolean { export function isWebGLSupported(): boolean {
const contextOptions = {stencil: true, failIfMajorPerformanceCaveat: true}; const contextOptions = { stencil: true, failIfMajorPerformanceCaveat: true };
try { try {
if (!window["WebGLRenderingContext"]) { if (!window["WebGLRenderingContext"]) {
return false; return false;
......
...@@ -28,7 +28,7 @@ export default class Container extends DisplayObject { ...@@ -28,7 +28,7 @@ export default class Container extends DisplayObject {
protected _renderWebGL(renderer: WebglRenderer): void; protected _renderWebGL(renderer: WebglRenderer): void;
renderCanvas(renderer: CanvasRenderer): void; renderCanvas(renderer: CanvasRenderer): void;
protected _renderCanvas(renderer: CanvasRenderer): void; protected _renderCanvas(renderer: CanvasRenderer): void;
update(): void; update(deltaTime: number): void;
_onDispatchBubbledEvent(type: string): void; _onDispatchBubbledEvent(type: string): void;
destroy(): void; destroy(): void;
width: number; width: number;
......
...@@ -66,7 +66,7 @@ export declare class DisplayObject extends EventDispatcher { ...@@ -66,7 +66,7 @@ export declare class DisplayObject extends EventDispatcher {
width: number; width: number;
height: number; height: number;
private _components; private _components;
update(): void; update(deltaTime: number): void;
addComponent(component: Component): void; addComponent(component: Component): void;
addComponentAt(component: Component, index: number): void; addComponentAt(component: Component, index: number): void;
removeComponent(component: Component): void; removeComponent(component: Component): void;
......
...@@ -7,7 +7,10 @@ export declare class Loader extends EventDispatcher { ...@@ -7,7 +7,10 @@ export declare class Loader extends EventDispatcher {
_req: XMLHttpRequest; _req: XMLHttpRequest;
constructor(); constructor();
loadSheet(callback: Function, url: string): void; loadSheet(callback: Function, url: string): void;
loadImage(callback: Function, url: string, crossOrigin?: boolean): void; loadJson(callback: Function, url: string): void;
loadTexture(url: string, uuid?: any): void;
loadImage(callback: Function, url: string, crossOrigin?: boolean): HTMLImageElement;
loadSvga(callback: (suc: boolean, data: VideoEntity) => void, url: string): void; loadSvga(callback: (suc: boolean, data: VideoEntity) => void, url: string): void;
cache(name: string, data: any): void; cache(name: string, data: any): void;
} }
export declare const globalLoader: Loader;
...@@ -36,6 +36,6 @@ export declare class MovieClip extends Container { ...@@ -36,6 +36,6 @@ export declare class MovieClip extends Container {
commonDeltaTime: number; commonDeltaTime: number;
updateFrame(): void; updateFrame(): void;
private getCurFrameWhenLockStep; private getCurFrameWhenLockStep;
update(): void; update(deltaTime: number): void;
destroy(): void; destroy(): void;
} }
...@@ -25,7 +25,7 @@ export declare class TextField extends Sprite { ...@@ -25,7 +25,7 @@ export declare class TextField extends Sprite {
private _font; private _font;
size: number; size: number;
private _size; private _size;
fillColor: string; fillColor: any;
private _fillColor; private _fillColor;
strokeColor: string; strokeColor: string;
private _strokeColor; private _strokeColor;
......
...@@ -31,6 +31,7 @@ export declare const GlobalPro: { ...@@ -31,6 +31,7 @@ export declare const GlobalPro: {
stageRenderType: RENDERER_TYPE; stageRenderType: RENDERER_TYPE;
dpi: number; dpi: number;
padding: number; padding: number;
startTime: number;
}; };
export declare function isWebGLSupported(): boolean; export declare function isWebGLSupported(): boolean;
export declare function removeItems(arr: Array<any>, startIdx: number, removeCount: number): void; export declare function removeItems(arr: Array<any>, startIdx: number, removeCount: number): void;
......
export declare function loadTexture(url: string): void;
export declare function getRes(): void;
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