Commit 600d7f46 authored by wjf's avatar wjf

l

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