新增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; unload(): void;
onActive(): void; onActive(): void;
onDeactive(): void; onDeactive(): void;
begin(): Promise<void>; begin(): void;
end(): void; end(): void;
update(): void; update(): void;
render(): void; render(): void;
@@ -1257,6 +1257,7 @@ declare module es {
private _alpha; private _alpha;
constructor(sceneLoadAction: Function); constructor(sceneLoadAction: Function);
onBeginTransition(): Promise<void>; onBeginTransition(): Promise<void>;
protected transitionComplete(): void;
render(): void; render(): void;
} }
} }
@@ -1270,6 +1271,7 @@ declare module es {
windSegments: number; windSegments: number;
size: number; size: number;
onBeginTransition(): Promise<void>; onBeginTransition(): Promise<void>;
protected transitionComplete(): void;
} }
} }
declare module es { declare module es {
+13 -5
View File
@@ -1675,8 +1675,6 @@ var es;
Scene.prototype.onDeactive = function () { Scene.prototype.onDeactive = function () {
}; };
Scene.prototype.begin = function () { Scene.prototype.begin = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (this._renderers.length == 0) { if (this._renderers.length == 0) {
this.addRenderer(new es.DefaultRenderer()); this.addRenderer(new es.DefaultRenderer());
console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染"); console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染");
@@ -1690,9 +1688,6 @@ var es;
this.camera.onSceneSizeChanged(this.stage.stageWidth, this.stage.stageHeight); this.camera.onSceneSizeChanged(this.stage.stageWidth, this.stage.stageHeight);
this._didSceneBegin = true; this._didSceneBegin = true;
this.onStart(); this.onStart();
return [2];
});
});
}; };
Scene.prototype.end = function () { Scene.prototype.end = function () {
this._didSceneBegin = false; this._didSceneBegin = false;
@@ -5865,6 +5860,8 @@ var es;
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var _this = this; var _this = this;
return __generator(this, function (_a) { 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.beginFill(this.fadeToColor, 1);
this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
this._mask.graphics.endFill(); 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 () { FadeTransition.prototype.render = function () {
this._mask.graphics.clear(); this._mask.graphics.clear();
this._mask.graphics.beginFill(this.fadeToColor, this._alpha); 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.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
_this._mask.graphics.endFill(); _this._mask.graphics.endFill();
_this._mask.filters = [_this._windEffect]; _this._mask.filters = [_this._windEffect];
es.Core.scene.stage.addChild(_this._mask);
return _this; return _this;
} }
Object.defineProperty(WindTransition.prototype, "windSegments", { 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; return WindTransition;
}(es.SceneTransition)); }(es.SceneTransition));
es.WindTransition = WindTransition; 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/loading/UI_View_loading.js",
"bin-debug/Fgui/sc/scBinder.js", "bin-debug/Fgui/sc/scBinder.js",
"bin-debug/Fgui/sc/UI_btn_sc.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/Fgui/sc/UI_View_sc.js",
"bin-debug/Platform.js", "bin-debug/Platform.js",
"bin-debug/Scenes/Animated Tiles/AnimatedTilesScene.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 { export class UI_View_sc extends fairygui.GComponent {
public m_list_sc:fairygui.GList; public m_list_sc:fairygui.GList;
public m_combo_transition:fairygui.GComboBox;
public static URL:string = "ui://m4sln17ak7mf0"; public static URL:string = "ui://m4sln17ak7mf0";
public static createInstance():UI_View_sc { public static createInstance():UI_View_sc {
@@ -14,6 +15,7 @@ module FUI.sc {
super.constructFromXML(xml); super.constructFromXML(xml);
this.m_list_sc = <fairygui.GList>(this.getChildAt(0)); 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 { export class scBinder {
public static bindAll():void { 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_View_sc.URL, UI_View_sc);
fairygui.UIObjectFactory.setPackageItemExtension(UI_btn_sc.URL, UI_btn_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), new SceneData("Ninja Adventure", samples.NinjaAdventureScene),
]; ];
private _transitionList: TransitionData[] = [
new TransitionData("渐变", es.FadeTransition),
new TransitionData("wind", es.WindTransition),
];
constructor() { constructor() {
super("sc"); super("sc");
} }
@@ -22,6 +27,11 @@ module sc {
this._ui.m_list_sc.callbackThisObj = this; this._ui.m_list_sc.callbackThisObj = this;
this._ui.m_list_sc.itemRenderer = this.scItemRender; this._ui.m_list_sc.itemRenderer = this.scItemRender;
this._ui.m_list_sc.numItems = this._sceneList.length; 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){ public scItemRender(index: number, item: FUI.sc.UI_btn_sc){
@@ -33,7 +43,8 @@ module sc {
private scItemOnClick(evt: egret.Event){ private scItemOnClick(evt: egret.Event){
let data = evt.currentTarget.data; 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; es.Core.scene.camera.position = es.Vector2.zero;
return new data(); return new data();
})); }));
@@ -57,4 +68,14 @@ module sc {
this.type = type; this.type = type;
} }
} }
export class TransitionData {
public name: string;
public type: any;
constructor(name: string, type: any){
this.name = name;
this.type = type;
}
}
} }
+4
View File
@@ -2,5 +2,9 @@
<component size="640,1136" opaque="false"> <component size="640,1136" opaque="false">
<displayList> <displayList>
<list id="n0_k7mf" name="list_sc" xy="0,0" size="211,1136" overflow="scroll" lineGap="20" colGap="11" defaultItem="ui://m4sln17ak7mf2" align="center"/> <list id="n0_k7mf" name="list_sc" xy="0,0" size="211,1136" overflow="scroll" lineGap="20" colGap="11" defaultItem="ui://m4sln17ak7mf2" align="center"/>
<component id="n2_jde1" name="combo_transition" src="jde15" fileName="组件/combo_sc.xml" xy="535,4" pivot="0.5,0.5">
<ComboBox visibleItemCount="10"/>
</component>
<text id="n3_jde1" name="n3" xy="424,4" pivot="0.5,0.5" size="105,24" fontSize="16" text="场景切换方式:"/>
</displayList> </displayList>
</component> </component>
+3
View File
@@ -3,6 +3,9 @@
<resources> <resources>
<component id="k7mf0" name="View_sc.xml" path="/" exported="true"/> <component id="k7mf0" name="View_sc.xml" path="/" exported="true"/>
<component id="k7mf2" name="btn_sc.xml" path="/组件/" exported="true"/> <component id="k7mf2" name="btn_sc.xml" path="/组件/" exported="true"/>
<component id="jde13" name="combo_sc_item.xml" path="/组件/"/>
<component id="jde14" name="combo_sc_popup.xml" path="/组件/"/>
<component id="jde15" name="combo_sc.xml" path="/组件/" exported="true"/>
</resources> </resources>
<publish name="" genCode="true"/> <publish name="" genCode="true"/>
</packageDescription> </packageDescription>
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<component size="100,20" extention="ComboBox">
<ComboBox dropdown="ui://m4sln17ajde14"/>
<controller name="button" pages="0,up,1,down,2,over,3,selectedOver"/>
<displayList>
<graph id="n0_jde1" name="n0" xy="0,0" size="100,20" type="rect" lineSize="0" fillColor="#F0F0F0" touchable="false">
<gearDisplay controller="button" pages="0"/>
<relation target="" sidePair="width,height"/>
</graph>
<graph id="n1_jde1" name="n1" xy="0,0" size="100,20" type="rect" lineSize="0" fillColor="#FAFAFA" touchable="false">
<gearDisplay controller="button" pages="2"/>
<relation target="" sidePair="width,height"/>
</graph>
<graph id="n2_jde1" name="n2" xy="0,0" size="100,20" type="rect" lineSize="0" fillColor="#CCCCCC" touchable="false">
<gearDisplay controller="button" pages="1,3"/>
<relation target="" sidePair="width,height"/>
</graph>
<text id="n3_jde1" name="title" xy="0,0" size="80,20" fontSize="16" autoSize="none" vAlign="middle" singleLine="true">
<relation target="" sidePair="width,height"/>
</text>
</displayList>
</component>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<component size="100,20" extention="Button">
<Button mode="Radio"/>
<controller name="button" pages="0,up,1,down,2,over,3,selectedOver"/>
<displayList>
<graph id="n0_jde1" name="n0" xy="0,0" size="100,20" type="rect" lineSize="0" fillColor="#3399FF" touchable="false">
<gearDisplay controller="button" pages="2"/>
<relation target="" sidePair="width,height"/>
</graph>
<graph id="n1_jde1" name="n1" xy="0,0" size="100,20" type="rect" lineSize="0" fillColor="#CCCCCC" touchable="false">
<gearDisplay controller="button" pages="1,3"/>
<relation target="" sidePair="width,height"/>
</graph>
<text id="n2_jde1" name="title" xy="0,0" size="100,20" fontSize="16" autoSize="none" vAlign="middle" singleLine="true">
<relation target="" sidePair="width,height"/>
</text>
</displayList>
</component>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<component size="150,200">
<displayList>
<graph id="n0_jde1" name="n0" xy="0,0" size="150,200" type="rect" lineSize="1" lineColor="#A0A0A0" fillColor="#F0F0F0" touchable="false">
<relation target="" sidePair="width,height"/>
</graph>
<list id="n1_jde1" name="list" xy="0,0" size="150,200" overflow="scroll" defaultItem="ui://m4sln17ajde13">
<relation target="" sidePair="width"/>
</list>
</displayList>
<relation target="n1_jde1" sidePair="height"/>
</component>
+3 -1
View File
@@ -374,7 +374,7 @@ declare module es {
unload(): void; unload(): void;
onActive(): void; onActive(): void;
onDeactive(): void; onDeactive(): void;
begin(): Promise<void>; begin(): void;
end(): void; end(): void;
update(): void; update(): void;
render(): void; render(): void;
@@ -1257,6 +1257,7 @@ declare module es {
private _alpha; private _alpha;
constructor(sceneLoadAction: Function); constructor(sceneLoadAction: Function);
onBeginTransition(): Promise<void>; onBeginTransition(): Promise<void>;
protected transitionComplete(): void;
render(): void; render(): void;
} }
} }
@@ -1270,6 +1271,7 @@ declare module es {
windSegments: number; windSegments: number;
size: number; size: number;
onBeginTransition(): Promise<void>; onBeginTransition(): Promise<void>;
protected transitionComplete(): void;
} }
} }
declare module es { declare module es {
+13 -5
View File
@@ -1675,8 +1675,6 @@ var es;
Scene.prototype.onDeactive = function () { Scene.prototype.onDeactive = function () {
}; };
Scene.prototype.begin = function () { Scene.prototype.begin = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (this._renderers.length == 0) { if (this._renderers.length == 0) {
this.addRenderer(new es.DefaultRenderer()); this.addRenderer(new es.DefaultRenderer());
console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染"); console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染");
@@ -1690,9 +1688,6 @@ var es;
this.camera.onSceneSizeChanged(this.stage.stageWidth, this.stage.stageHeight); this.camera.onSceneSizeChanged(this.stage.stageWidth, this.stage.stageHeight);
this._didSceneBegin = true; this._didSceneBegin = true;
this.onStart(); this.onStart();
return [2];
});
});
}; };
Scene.prototype.end = function () { Scene.prototype.end = function () {
this._didSceneBegin = false; this._didSceneBegin = false;
@@ -5865,6 +5860,8 @@ var es;
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var _this = this; var _this = this;
return __generator(this, function (_a) { 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.beginFill(this.fadeToColor, 1);
this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
this._mask.graphics.endFill(); 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 () { FadeTransition.prototype.render = function () {
this._mask.graphics.clear(); this._mask.graphics.clear();
this._mask.graphics.beginFill(this.fadeToColor, this._alpha); 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.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
_this._mask.graphics.endFill(); _this._mask.graphics.endFill();
_this._mask.filters = [_this._windEffect]; _this._mask.filters = [_this._windEffect];
es.Core.scene.stage.addChild(_this._mask);
return _this; return _this;
} }
Object.defineProperty(WindTransition.prototype, "windSegments", { 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; return WindTransition;
}(es.SceneTransition)); }(es.SceneTransition));
es.WindTransition = WindTransition; es.WindTransition = WindTransition;
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -85,7 +85,7 @@ module es {
public onDeactive() { public onDeactive() {
} }
public async begin() { public begin() {
if (this._renderers.length == 0) { if (this._renderers.length == 0) {
this.addRenderer(new DefaultRenderer()); this.addRenderer(new DefaultRenderer());
console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染"); console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染");
@@ -14,6 +14,9 @@ module es {
} }
public async onBeginTransition() { public async onBeginTransition() {
if (!this._mask.parent)
Core.scene.stage.addChild(this._mask);
this._mask.graphics.beginFill(this.fadeToColor, 1); this._mask.graphics.beginFill(this.fadeToColor, 1);
this._mask.graphics.drawRect(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height); this._mask.graphics.drawRect(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height);
this._mask.graphics.endFill(); this._mask.graphics.endFill();
@@ -28,6 +31,13 @@ module es {
}); });
} }
protected transitionComplete(){
super.transitionComplete();
if (this._mask.parent)
this._mask.parent.removeChild(this._mask);
}
public render() { public render() {
this._mask.graphics.clear(); this._mask.graphics.clear();
this._mask.graphics.beginFill(this.fadeToColor, this._alpha); this._mask.graphics.beginFill(this.fadeToColor, this._alpha);
@@ -48,6 +48,7 @@ module es {
this._mask.graphics.drawRect(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height); this._mask.graphics.drawRect(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height);
this._mask.graphics.endFill(); this._mask.graphics.endFill();
this._mask.filters = [this._windEffect]; this._mask.filters = [this._windEffect];
Core.scene.stage.addChild(this._mask);
} }
public set windSegments(value: number) { public set windSegments(value: number) {
@@ -63,5 +64,12 @@ module es {
await this.tickEffectProgressProperty(this._windEffect, this.duration, this.easeType); await this.tickEffectProgressProperty(this._windEffect, this.duration, this.easeType);
this.transitionComplete(); this.transitionComplete();
} }
protected transitionComplete() {
super.transitionComplete();
if (this._mask.parent)
this._mask.parent.removeChild(this._mask);
}
} }
} }