新增windTransition例子

This commit is contained in:
yhh
2020-08-25 17:28:22 +08:00
parent 794e33a0a0
commit 46a8de39e3
20 changed files with 183 additions and 42 deletions
+3 -1
View File
@@ -374,7 +374,7 @@ declare module es {
unload(): void;
onActive(): void;
onDeactive(): void;
begin(): Promise<void>;
begin(): void;
end(): void;
update(): void;
render(): void;
@@ -1257,6 +1257,7 @@ declare module es {
private _alpha;
constructor(sceneLoadAction: Function);
onBeginTransition(): Promise<void>;
protected transitionComplete(): void;
render(): void;
}
}
@@ -1270,6 +1271,7 @@ declare module es {
windSegments: number;
size: number;
onBeginTransition(): Promise<void>;
protected transitionComplete(): void;
}
}
declare module es {
+26 -18
View File
@@ -1675,24 +1675,19 @@ var es;
Scene.prototype.onDeactive = function () {
};
Scene.prototype.begin = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (this._renderers.length == 0) {
this.addRenderer(new es.DefaultRenderer());
console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染");
}
this.camera = this.createEntity("camera").getOrCreateComponent(new es.Camera());
es.Physics.reset();
if (this.entityProcessors)
this.entityProcessors.begin();
this.addEventListener(egret.Event.ACTIVATE, this.onActive, this);
this.addEventListener(egret.Event.DEACTIVATE, this.onDeactive, this);
this.camera.onSceneSizeChanged(this.stage.stageWidth, this.stage.stageHeight);
this._didSceneBegin = true;
this.onStart();
return [2];
});
});
if (this._renderers.length == 0) {
this.addRenderer(new es.DefaultRenderer());
console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染");
}
this.camera = this.createEntity("camera").getOrCreateComponent(new es.Camera());
es.Physics.reset();
if (this.entityProcessors)
this.entityProcessors.begin();
this.addEventListener(egret.Event.ACTIVATE, this.onActive, this);
this.addEventListener(egret.Event.DEACTIVATE, this.onDeactive, this);
this.camera.onSceneSizeChanged(this.stage.stageWidth, this.stage.stageHeight);
this._didSceneBegin = true;
this.onStart();
};
Scene.prototype.end = function () {
this._didSceneBegin = false;
@@ -5865,6 +5860,8 @@ var es;
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
if (!this._mask.parent)
es.Core.scene.stage.addChild(this._mask);
this._mask.graphics.beginFill(this.fadeToColor, 1);
this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
this._mask.graphics.endFill();
@@ -5887,6 +5884,11 @@ var es;
});
});
};
FadeTransition.prototype.transitionComplete = function () {
_super.prototype.transitionComplete.call(this);
if (this._mask.parent)
this._mask.parent.removeChild(this._mask);
};
FadeTransition.prototype.render = function () {
this._mask.graphics.clear();
this._mask.graphics.beginFill(this.fadeToColor, this._alpha);
@@ -5938,6 +5940,7 @@ var es;
_this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
_this._mask.graphics.endFill();
_this._mask.filters = [_this._windEffect];
es.Core.scene.stage.addChild(_this._mask);
return _this;
}
Object.defineProperty(WindTransition.prototype, "windSegments", {
@@ -5969,6 +5972,11 @@ var es;
});
});
};
WindTransition.prototype.transitionComplete = function () {
_super.prototype.transitionComplete.call(this);
if (this._mask.parent)
this._mask.parent.removeChild(this._mask);
};
return WindTransition;
}(es.SceneTransition));
es.WindTransition = WindTransition;
File diff suppressed because one or more lines are too long
+1
View File
@@ -23,6 +23,7 @@
"bin-debug/Fgui/loading/UI_View_loading.js",
"bin-debug/Fgui/sc/scBinder.js",
"bin-debug/Fgui/sc/UI_btn_sc.js",
"bin-debug/Fgui/sc/UI_combo_sc_popup.js",
"bin-debug/Fgui/sc/UI_View_sc.js",
"bin-debug/Platform.js",
"bin-debug/Scenes/Animated Tiles/AnimatedTilesScene.js",
Binary file not shown.
+2
View File
@@ -4,6 +4,7 @@ module FUI.sc {
export class UI_View_sc extends fairygui.GComponent {
public m_list_sc:fairygui.GList;
public m_combo_transition:fairygui.GComboBox;
public static URL:string = "ui://m4sln17ak7mf0";
public static createInstance():UI_View_sc {
@@ -14,6 +15,7 @@ module FUI.sc {
super.constructFromXML(xml);
this.m_list_sc = <fairygui.GList>(this.getChildAt(0));
this.m_combo_transition = <fairygui.GComboBox>(this.getChildAt(1));
}
}
}
+19
View File
@@ -0,0 +1,19 @@
/** This is an automatically generated class by FairyGUI. Please do not modify it. **/
module FUI.sc {
export class UI_combo_sc_popup extends fairygui.GComponent {
public m_list:fairygui.GList;
public static URL:string = "ui://m4sln17ajde14";
public static createInstance():UI_combo_sc_popup {
return <UI_combo_sc_popup>(fairygui.UIPackage.createObject("sc", "combo_sc_popup"));
}
protected constructFromXML(xml:any):void {
super.constructFromXML(xml);
this.m_list = <fairygui.GList>(this.getChildAt(1));
}
}
}
+1
View File
@@ -4,6 +4,7 @@ module FUI.sc {
export class scBinder {
public static bindAll():void {
fairygui.UIObjectFactory.setPackageItemExtension(UI_combo_sc_popup.URL, UI_combo_sc_popup);
fairygui.UIObjectFactory.setPackageItemExtension(UI_View_sc.URL, UI_View_sc);
fairygui.UIObjectFactory.setPackageItemExtension(UI_btn_sc.URL, UI_btn_sc);
}
+22 -1
View File
@@ -8,6 +8,11 @@ module sc {
new SceneData("Ninja Adventure", samples.NinjaAdventureScene),
];
private _transitionList: TransitionData[] = [
new TransitionData("渐变", es.FadeTransition),
new TransitionData("wind", es.WindTransition),
];
constructor() {
super("sc");
}
@@ -22,6 +27,11 @@ module sc {
this._ui.m_list_sc.callbackThisObj = this;
this._ui.m_list_sc.itemRenderer = this.scItemRender;
this._ui.m_list_sc.numItems = this._sceneList.length;
for (let i = 0; i < this._transitionList.length; i ++){
this._ui.m_combo_transition.items.push(this._transitionList[i].name);
}
this._ui.m_combo_transition.selectedIndex = 0;
}
public scItemRender(index: number, item: FUI.sc.UI_btn_sc){
@@ -33,7 +43,8 @@ module sc {
private scItemOnClick(evt: egret.Event){
let data = evt.currentTarget.data;
es.Core.startSceneTransition(new es.FadeTransition(()=>{
let currentTransition = this._transitionList[this._ui.m_combo_transition.selectedIndex].type;
es.Core.startSceneTransition(new currentTransition(()=>{
es.Core.scene.camera.position = es.Vector2.zero;
return new data();
}));
@@ -57,4 +68,14 @@ module sc {
this.type = type;
}
}
export class TransitionData {
public name: string;
public type: any;
constructor(name: string, type: any){
this.name = name;
this.type = type;
}
}
}