Commit c7991a66 authored by wjf's avatar wjf

l

parent f2b1003a
resource/playScene/guidePropHand.png

7.17 KB | W: | H:

resource/playScene/guidePropHand.png

8.16 KB | W: | H:

resource/playScene/guidePropHand.png
resource/playScene/guidePropHand.png
resource/playScene/guidePropHand.png
resource/playScene/guidePropHand.png
  • 2-up
  • Swipe
  • Onion skin
This diff is collapsed.
import { removeTweens } from "../module/ctrls";
interface LottieData {
"fr": number,//珍露 30 60等
"ip": number,//开始帧
"op": number,//结束帧
"w": number,//宽度
"h": number,//高度
"nm": string,//名字
"layers": LayerData[]
}
interface LayerData {
"ind": number,//id唯一
"ty": number,//类型,暂时只有2
"nm": "owl_sleep.png",//暂时就是图片
"parent"?: number,//父级id
"ks": KsData;
"ip": number,//开始帧
"op": number,//结束帧
}
interface KsData {
o: KeyData
r: KeyData
p: KeyData
a: KeyData
s: KeyData
}
interface KeyData {
a: number, k: { "t": number, "s": number[] }[] | number[] | number, x: string
}
/**
* 记录的Tween数据
*/
interface TweenData {
/**
* 显示对象
*/
dis: FYGE.DisplayObject
/**
* 数据
*/
ks: { frame: number, value: number[] }[]
}
/**
* 用Tween拼,后续计算帧数据记录
* 临时写的,乱得很,以后再说
*/
export class Lottie extends FYGE.Container {
rawData: LottieData;
totalTime: number;
totalFrames: number;
/**
* 锁步的时间间隔,按fps定,毫秒
*/
private timeInterval;
/**
* 按帧率计算,60为1,30为2,
*/
private deltaFrame: number = 1;
/**
* 所有带动效的对象
*/
private tweenDatas: TweenData[];
get videoWidth(): number {
return this.rawData && this.rawData.w;
};
get videoHeight(): number {
return this.rawData && this.rawData.h;
};
/**
* 供循环用
*/
private loops: number
private callback: () => void
// private
constructor(data) {
super()
this._instanceType = "MovieClip";
//初始化
if (data) {
this.init(data);
} else {
this.totalFrames = 0;
}
}
init(data: LottieData) {
if (!data) return
this.rawData = data;
this.timeInterval = 1000 / data.fr;
this.totalFrames = data.op - data.ip
//间隔帧数,
this.deltaFrame = 60 / data.fr;
this.name = data.nm;
this.initChildren();
}
private initChildren() {
const hash = {};
//初始化内容吧,假设所有资源已经加载好额
var layers = this.rawData.layers.slice();
//先筛选出所有不带parents,说明是顶级容器
for (var i = layers.length - 1; i >= 0; i--) {
let layer = layers[i];
if (!layer.parent) {
let c = this.addChild(new FYGE.Container())
c.addChild(FYGE.Sprite.fromFrame(layer.nm));
c.name = layer.nm;
//记录一下数据
c["layerData"] = layer;
//计入hash
hash[layer.ind] = c;
//从数组移除
layers.splice(i, 1);
}
}
//剩下就找爹了
while (layers.length) {
for (var j = layers.length - 1; j >= 0; j--) {
let layer = layers[j];
if (hash[layer.parent]) {
let c = hash[layer.parent].addChild(FYGE.Sprite.fromFrame(layer.nm));
c.name = layer.nm;
//记录一下数据
c["layerData"] = layer;
//计入hash
hash[layer.ind] = c;
//从数组移除
layers.splice(j, 1);
}
}
}
this.initState()
}
private initState(con = this.children) {
for (var i = 0; i < con.length; i++) {
var c: FYGE.Sprite = con[i];
if (c["layerData"]) {
//取第一个数据
let data: LayerData = c["layerData"];
//@ts-ignore 透明度
c.alpha = data.ks.o.k[0] ? data.ks.o.k[0].s[0] : data.ks.o.k / 100;
//@ts-ignore 选转
c.rotation = data.ks.r.k[0] ? data.ks.r.k[0].s[0] : data.ks.r.k / 100;
//锚点,用贴图锚点
var ad = typeof data.ks.a.k[0] == "number" ? data.ks.a.k : data.ks.a.k[0].s;
c.anchor.set(ad[0], ad[1])
//位置
var ad = typeof data.ks.p.k[0] == "number" ? data.ks.p.k : data.ks.p.k[0].s;
c.position.set(ad[0] - c.anchorX, ad[1] - c.anchorY)
//缩放
var ad = typeof data.ks.s.k[0] == "number" ? data.ks.s.k : data.ks.s.k[0].s;
c.scale.set(ad[0] / 100, ad[1] / 100)
//如果入场不在的
if (data.ip != 0) c.visible = false
}
if (c.children.length) this.initState(c.children)
}
}
/**
* 只有一次或无数次
*/
play(loop: number = 1, callback?: () => void) {
this.initState();
this.loops = loop;
this.callback = callback;
this.addTweens();
}
/**
* 移除所有的Tween
*/
stop() {
removeTweens(this);
this.initState();
}
private addTweens(con = this.children) {
for (var i = 0; i < con.length; i++) {
let c: FYGE.Sprite = con[i];
if (c["layerData"]) {
//取第一个数据
let data: LayerData = c["layerData"];
//@ts-ignore 透明度,如果k是数组,肯定有帧数据
if (data.ks.o.k.length) this.addTween(c, "o");
//@ts-ignore 旋转
if (data.ks.r.k.length) this.addTween(c, "r");
//位置,得是对象
if (typeof data.ks.p.k[0] != "number") this.addTween(c, "p");
//缩放
if (typeof data.ks.s.k[0] != "number") this.addTween(c, "s");
}
if (c.children.length) this.addTweens(c.children)
}
}
private addTween(dis: FYGE.DisplayObject, type: "r" | "o" | "s" | "p") {
const data: { "t": number, "s": number[] }[] = dis["layerData"].ks[type].k
let tween = FYGE.Tween.get(dis, { loop: true })
let countTime = 0;
//记录用过的obj
var objArr: { obj: any, deltaTime: number }[] = []
for (let i = 0; i < data.length; i++) {
let d = data[i];
let deltaTime = d.t * this.timeInterval - countTime;
countTime += deltaTime;
let obj;
switch (type) {
case "r":
obj = { rotation: d.s[0] }
break;
case "o":
obj = { alpha: d.s[0] }
break;
case "s":
obj = { scaleX: d.s[0] / 100, scaleY: d.s[1] / 100 }
break;
case "p":
obj = { x: d.s[0] - dis.anchorX, y: d.s[1] - dis.anchorY }
break;
}
//第一个不是0,加wait
if (i == 0 && d.t != 0) {
tween.wait(deltaTime)
.call(() => { dis.visible = true })
continue
} else if (i == 0 && d.t == 0) {//从0开始的,不进行缓动,但是要记录状态
objArr.push({ obj, deltaTime })
continue
}
tween.to(obj, deltaTime);
objArr.push({ obj, deltaTime })
}
if (dis["layerData"].ks[type].x) {
var xs = dis["layerData"].ks[type].x;
if (xs.indexOf("loopOut") >= 0) {
//如果是往复的,
if (xs.indexOf("pingpong") >= 0 && data[data.length - 1].t < this.rawData.op) {
var round = Math.round(this.rawData.op / data[data.length - 1].t)
var dir = false;
while (--round) {
if (dir) {
for (var o = 0; o < objArr.length; o++) {
tween.to(objArr[o].obj, objArr[o].deltaTime);
}
} else {
for (var o = objArr.length - 1; o >= 1; o--) {
tween.to(objArr[o - 1].obj, objArr[o].deltaTime);
}
}
dir = !dir;
}
}
//如果是循环的,且没满一个循环的
else if (xs.indexOf("cycle") >= 0 && data[data.length - 1].t < this.rawData.op) {
//补满
for (var o = 0; o < objArr.length; o++) {
tween.to(objArr[o].obj, objArr[o].deltaTime);
}
}
}
}
//入场不是0
if (dis["layerData"].ip != 0) {
tween.call(() => {
dis.visible = false;
})
}
//不管x的
if (!dis["layerData"].ks[type].x) {
if (data[data.length - 1].t < this.rawData.op) {
tween.wait(this.rawData.op * this.timeInterval - countTime)
}
}
tween.call(() => {
if (--this.loops == 0) {
this.stop();
this.callback && this.callback();
}
})
}
destroy(){
removeTweens(this);
super.destroy();
}
}
...@@ -112,7 +112,7 @@ export class Main { ...@@ -112,7 +112,7 @@ export class Main {
} }
//在小程序隐藏时调用onHide //在小程序隐藏时调用onHide
pause() { pause() {
this._pause = true // this._pause = true;//先去掉吧
GDispatcher.dispatchEvent(G_EVENT.ON_HIDE); GDispatcher.dispatchEvent(G_EVENT.ON_HIDE);
} }
......
This diff is collapsed.
...@@ -237,7 +237,7 @@ export const SkinJson = { ...@@ -237,7 +237,7 @@ export const SkinJson = {
] ]
}, },
{ {
"name": "NoStepBtn", "name": "NoStepPanel",
"x": 0, "x": 0,
"y": 0, "y": 0,
"type": "container", "type": "container",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -8,6 +8,8 @@ import { changeScene } from "../../module/ctrls"; ...@@ -8,6 +8,8 @@ import { changeScene } from "../../module/ctrls";
import { MapScene } from "./map/MapScene"; import { MapScene } from "./map/MapScene";
import { layers } from "../../module/views/layers"; import { layers } from "../../module/views/layers";
import { GTool } from "../../module/tools/GTool"; import { GTool } from "../../module/tools/GTool";
import { Lottie } from "../Lottie";
import { lottieConfig } from "../aa";
...@@ -44,6 +46,20 @@ export class LoadingScene extends Scene { ...@@ -44,6 +46,20 @@ export class LoadingScene extends Scene {
pro.position.set(375, 1288)//位置按正常满条的位置 pro.position.set(375, 1288)//位置按正常满条的位置
//@ts-ignore 进度条托管 //@ts-ignore 进度条托管
this.progressBar = new ProgressBarS(pro); this.progressBar = new ProgressBarS(pro);
//动画
var l = this.addChild(new Lottie(lottieConfig))
l.play(0)
//尾巴
var foxTail = new FYGE.FrameAni((() => {
var arrFox = [];
var count = -1;
while (++count <= 14) arrFox.push(RES.getRes("fox_tail" + count + ".png"))
return arrFox
})())
foxTail.play(0);
l.getChildByName("fox_body.png", true, true)
.addChildAt(foxTail, 0)
.position.set(250, 0)
//标题 //标题
this.addChild(new Title()) this.addChild(new Title())
...@@ -61,6 +77,9 @@ export class LoadingScene extends Scene { ...@@ -61,6 +77,9 @@ export class LoadingScene extends Scene {
(750 - 500) / 2, (750 - 500) / 2,
1288 - 24 + 18 + 48 1288 - 24 + 18 + 48
)) ))
} }
async start() { async start() {
......
...@@ -52,7 +52,7 @@ import { GTool } from '../../module/tools/GTool'; ...@@ -52,7 +52,7 @@ import { GTool } from '../../module/tools/GTool';
import { Tools } from '../Tools'; import { Tools } from '../Tools';
import { PropType } from '../something/enum/PropType'; import { PropType } from '../something/enum/PropType';
import { RES } from '../../module/RES'; import { RES } from '../../module/RES';
import { showToast, showWaiting, showPanel } from '../../module/ctrls'; import { showToast, showWaiting, showPanel, hideWaiting } from '../../module/ctrls';
import { layers } from '../../module/views/layers'; import { layers } from '../../module/views/layers';
import { ToolsOutPanel } from '../panels/ToolsOutPanel'; import { ToolsOutPanel } from '../panels/ToolsOutPanel';
...@@ -99,9 +99,9 @@ const movieClips: any = {} ...@@ -99,9 +99,9 @@ const movieClips: any = {}
//红包炸弹弹框名字 //红包炸弹弹框名字
const redBombPanelName = "RedBombAlert"; const redBombPanelName = "RedBombAlert";
//所有可能被添加节日红包的关卡及索引,默认索引值都是40;如果没有就不放 //所有可能被添加节日红包的关卡;如果没有就不放
const fesChapterData: number[] = [] const fesChapterData: number[] = []
//节日大红包格子索引 //节日大红包格子索引 及索引,默认索引值都是40
const festivalIndex: number = 40 const festivalIndex: number = 40
export class PlayScene extends Scene { export class PlayScene extends Scene {
...@@ -137,8 +137,6 @@ export class PlayScene extends Scene { ...@@ -137,8 +137,6 @@ export class PlayScene extends Scene {
isMouseAction: boolean isMouseAction: boolean
//选中的元素 //选中的元素
SELECTED: Element; SELECTED: Element;
//判断是否提示交换元素用
enableTouch: boolean;
//提示交换对象 //提示交换对象
warningCop: Element[]; warningCop: Element[];
//未操作的计时,点击元素时置0,点击道具时置0,动画也要去掉,在有些引导,道具操作时去掉计时侦听,使用完后加回 //未操作的计时,点击元素时置0,点击道具时置0,动画也要去掉,在有些引导,道具操作时去掉计时侦听,使用完后加回
...@@ -300,6 +298,7 @@ export class PlayScene extends Scene { ...@@ -300,6 +298,7 @@ export class PlayScene extends Scene {
this.upsetElement(); this.upsetElement();
} else { } else {
this.enableMouseEvt(true); this.enableMouseEvt(true);
//首次送道具,的动画先出,然后再出引导
//引导 //引导
this.initGuide(); this.initGuide();
} }
...@@ -775,9 +774,9 @@ export class PlayScene extends Scene { ...@@ -775,9 +774,9 @@ export class PlayScene extends Scene {
* 绝对别修改,其他地方有调用的 * 绝对别修改,其他地方有调用的
*/ */
updateScene() { updateScene() {
// this.propBtnCon.boomCount = Tools.gameData.tools.BOOMS; this.propBtnCon.boomCount = Tools.gameData.tools.BOOMS;
// this.propBtnCon.hammerCount = Tools.gameData.tools.HAMMERS; this.propBtnCon.hammerCount = Tools.gameData.tools.HAMMERS;
// this.propBtnCon.stepCount = Tools.gameData.tools.STEPS; this.propBtnCon.stepCount = Tools.gameData.tools.STEPS;
} }
//侦听事件 //侦听事件
...@@ -809,7 +808,7 @@ export class PlayScene extends Scene { ...@@ -809,7 +808,7 @@ export class PlayScene extends Scene {
} }
onEnterFrame() { onEnterFrame() {
if (this.enableTouch && !this.gameGuide) { if (this.mouseEnable && !this.gameGuide) {
this.noActionCount++; this.noActionCount++;
} else { } else {
this.noActionCount = 0; this.noActionCount = 0;
...@@ -968,6 +967,7 @@ export class PlayScene extends Scene { ...@@ -968,6 +967,7 @@ export class PlayScene extends Scene {
//接口 //接口
showWaiting(); showWaiting();
var s = await Tools.consumerTools(prop); var s = await Tools.consumerTools(prop);
hideWaiting();
//还原事件 //还原事件
this.addEventListener(FYGE.Event.ENTER_FRAME, this.onEnterFrame, this); this.addEventListener(FYGE.Event.ENTER_FRAME, this.onEnterFrame, this);
//区分 //区分
...@@ -1034,7 +1034,6 @@ export class PlayScene extends Scene { ...@@ -1034,7 +1034,6 @@ export class PlayScene extends Scene {
//现在有两级,element的showImage是FrameAni //现在有两级,element的showImage是FrameAni
var ele = e.currentTarget.parent.parent; var ele = e.currentTarget.parent.parent;
// console.log(e.currentTarget.parent.parent) // console.log(e.currentTarget.parent.parent)
// if (!this.enableTouch) return
var self = this; var self = this;
if (ele && ele instanceof Element) { if (ele && ele instanceof Element) {
//去掉提示动画 //去掉提示动画
......
import { ElementType } from "../enum/ElementType"; import { ElementType } from "../enum/ElementType";
import { RES } from "../../../module/RES"; import { RES } from "../../../module/RES";
import { Tools } from "../../Tools";
/** /**
...@@ -76,13 +77,13 @@ class ElementTarget extends FYGE.Container { ...@@ -76,13 +77,13 @@ class ElementTarget extends FYGE.Container {
this.addChild(showImage); this.addChild(showImage);
var texture: FYGE.Texture = RES.getRes("rightMark.png"); var texture: FYGE.Texture = RES.getRes("rightMark.png");
this.zeroMark = new FYGE.Sprite(texture); this.zeroMark = new FYGE.Sprite(texture);
this.zeroMark.x = 35; this.zeroMark.x = 35-10;
this.zeroMark.y = 35; this.zeroMark.y = 35-10;
this.zeroMark.visible = false; this.zeroMark.visible = false;
this.addChild(this.zeroMark); this.addChild(this.zeroMark);
this.countNum = new FYGE.BitmapText({});//文字待定 this.countNum = new FYGE.BitmapText(Tools.getNumTextures("tarNum"));//文字待定
this.countNum.x = 55; this.countNum.x = 55-10;
this.countNum.y = 45; this.countNum.y = 45-10;
this.addChild(this.countNum); this.addChild(this.countNum);
} }
} }
\ No newline at end of file
...@@ -18,12 +18,13 @@ export class GameGuide extends FYGE.Container { ...@@ -18,12 +18,13 @@ export class GameGuide extends FYGE.Container {
*/ */
bg: FYGE.Shape; bg: FYGE.Shape;
hand: FYGE.Sprite; hand: FYGE.Sprite;
msg: FYGE.TextField;
stepCount: number; stepCount: number;
stepAll: number; stepAll: number;
thisObj: PlayScene; thisObj: PlayScene;
msgBoard: MsgBoard
/** /**
* 直接把this传入得了 * 直接把this传入得了,懒得弄了
* @param thisObj * @param thisObj
*/ */
constructor(thisObj: PlayScene) { constructor(thisObj: PlayScene) {
...@@ -34,13 +35,8 @@ export class GameGuide extends FYGE.Container { ...@@ -34,13 +35,8 @@ export class GameGuide extends FYGE.Container {
this.hand = new FYGE.Sprite(RES.getRes("guidePropHand.png")); this.hand = new FYGE.Sprite(RES.getRes("guidePropHand.png"));
this.hand.mouseEnable = false; this.hand.mouseEnable = false;
this.addChild(this.hand); this.addChild(this.hand);
this.msg = new FYGE.TextField();
this.msg.size = 22; this.msgBoard = this.addChild(new MsgBoard());
this.msg.y = 850;
this.msg.fillColor = "#ffffff";
this.msg.lineSpacing = 10;
this.msg.textAlign = FYGE.TEXT_ALIGN.CENTER;
this.addChild(this.msg);
this.thisObj = thisObj this.thisObj = thisObj
this.stepCount = chapterFuns[thisObj.chapter] ? chapterFuns[thisObj.chapter].stepCount : 0; this.stepCount = chapterFuns[thisObj.chapter] ? chapterFuns[thisObj.chapter].stepCount : 0;
...@@ -61,14 +57,14 @@ export class GameGuide extends FYGE.Container { ...@@ -61,14 +57,14 @@ export class GameGuide extends FYGE.Container {
} }
this.handAni(handIndexs); this.handAni(handIndexs);
this.msg.text = chapterFuns[this.thisObj.chapter].msg[step] || ""; this.msgBoard.msg = chapterFuns[this.thisObj.chapter].msg[step] || "";
this.msg.x = (750 - this.msg.textWidth) / 2; this.msgBoard.x = (750 - this.msgBoard.width) / 2;
var p1 = Tool.getPositionByIndex(handIndexs[0]); var p1 = Tool.getPositionByIndex(handIndexs[0]);
var p2 = Tool.getPositionByIndex(handIndexs[1]); var p2 = Tool.getPositionByIndex(handIndexs[1]);
this.msg.y = Math.max(p1[1], p2[1]) + 135; this.msgBoard.y = Math.max(p1[1], p2[1]) + 135;
//定制修改,101关毛球引导, //定制修改,101关毛球引导,
if (this.thisObj.chapter == 101 && step == 0) { if (this.thisObj.chapter == 101 && step == 0) {
this.msg.y += 80; this.msgBoard.y += 80;
} }
this.stepCount--; this.stepCount--;
...@@ -121,6 +117,31 @@ export class GameGuide extends FYGE.Container { ...@@ -121,6 +117,31 @@ export class GameGuide extends FYGE.Container {
} }
} }
/**
* 提示板
*/
class MsgBoard extends FYGE.Sprite {
private _msg: FYGE.TextField
set msg(value) {
this._msg.text = value
}
constructor() {
super(RES.getRes("gameGuideBoard.png"));
var msg = this.addChild(Tools.getText(
"",
30,
"#df5942",
FYGE.TEXT_ALIGN.LEFT,
330,
258,
14
))
msg.textHeight = 166;
msg.verticalAlign = FYGE.VERTICAL_ALIGN.MIDDLE;
msg.lineType = FYGE.TEXT_lINETYPE.MULTI;
this._msg = msg;
}
}
const chapterFuns = { const chapterFuns = {
//基本操作 1 //基本操作 1
...@@ -351,7 +372,7 @@ const chapterFuns = { ...@@ -351,7 +372,7 @@ const chapterFuns = {
[13, 22] [13, 22]
], ],
msg: [ msg: [
"灰毛球每步会随机选择\n相邻的格子跳动~\n移动一步试试吧" "灰毛球每步会随机选择相邻的格子跳动~\n移动一步试试吧"
] ]
}, },
//褐色毛球 //褐色毛球
...@@ -392,7 +413,7 @@ function drawHole(shape: FYGE.Shape, showIndexs: number[], hideIndexs: number[]) ...@@ -392,7 +413,7 @@ function drawHole(shape: FYGE.Shape, showIndexs: number[], hideIndexs: number[])
//根据hideIndexs画遮,为了不能点击 //根据hideIndexs画遮,为了不能点击
if (!hideIndexs || !hideIndexs.length) return if (!hideIndexs || !hideIndexs.length) return
shape.beginFill(0x000000, 0); shape.beginFill(0x000000, 0.01);//为了能用这个遮挡,必须设置0.01
for (var i = 0; i < hideIndexs.length; i++) { for (var i = 0; i < hideIndexs.length; i++) {
var center = Tool.getPositionByIndex(hideIndexs[i]); var center = Tool.getPositionByIndex(hideIndexs[i]);
shape.drawRect(center[0] - Tool.width / 2, center[1] - Tool.height / 2, Tool.width, Tool.height); shape.drawRect(center[0] - Tool.width / 2, center[1] - Tool.height / 2, Tool.width, Tool.height);
......
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