Commit 1a1c751b authored by wjf's avatar wjf

l

parent 276189de
......@@ -45,11 +45,11 @@ export default class Container extends DisplayObject {
}
/**
* 添加child
* 添加child,返回的就是child
* @param {DisplayObject} child
* @return {DisplayObject}
*/
addChild(child: DisplayObject): DisplayObject {
addChild<T extends DisplayObject>(child: T): T {
//默认添加在最顶层
this.addChildAt(child, this.children.length);
return child;
......@@ -61,7 +61,7 @@ export default class Container extends DisplayObject {
* @param {number} index - The index to place the child in
* @return {DisplayObject} The child that was added.
*/
addChildAt(child: DisplayObject, index: number): DisplayObject {
addChildAt<T extends DisplayObject>(child: T, index: number): T {
if (!child) return;
let s = this;
......
......@@ -62,7 +62,7 @@ export class EventDispatcher extends HashObject {
}
/**
* 给对象添加一个侦听
* 给对象添加一个侦听,返回自身
* @method addEventListener
* @public
* @since 1.0.0
......@@ -73,7 +73,7 @@ export class EventDispatcher extends HashObject {
* @example
* this.addEventListener(Event.ADD_TO_STAGE,function(e){trace(this);},this);
*/
public addEventListener(type: string, listener: Function, context?: any, useCapture: boolean = true): void {
public addEventListener(type: string, listener: Function, context?: any, useCapture: boolean = true): this {
if (!type) {
throw new Error("添加侦听的type值为undefined");
}
......@@ -106,17 +106,17 @@ export class EventDispatcher extends HashObject {
if (type.indexOf("onMouse") == 0) {
s._changeMouseCount(type, true);
}
return s
}
/**
* 监听一次
* 监听一次,返回自身
* @param type
* @param listener
* @param context
* @param useCapture
*/
public once(type: string, listener: Function, context?: any, useCapture: boolean = true): void {
public once(type: string, listener: Function, context?: any, useCapture: boolean = true): this {
if (!type) {
throw new Error("添加侦听的type值为undefined");
}
......@@ -136,6 +136,7 @@ export class EventDispatcher extends HashObject {
if (type.indexOf("onMouse") == 0) {
s._changeMouseCount(type, true);
}
return s
}
/**
......@@ -246,7 +247,7 @@ export class EventDispatcher extends HashObject {
}
/**
* 移除对应类型的侦听
* 移除对应类型的侦听,返回自身
* @method removeEventListener
* @public
* @since 1.0.0
......@@ -255,7 +256,7 @@ export class EventDispatcher extends HashObject {
* @param context listener和context都相等的才移除,默认自身
* @param {boolean} useCapture true 捕获阶段 false 冒泡阶段 默认 true
*/
public removeEventListener(type: string, listener: Function, context?: any, useCapture: boolean = true): void {
public removeEventListener(type: string, listener: Function, context?: any, useCapture: boolean = true): this {
let s = this;
let listeners: EE[] = s.eventTypes[type];
if (!useCapture) {
......@@ -279,15 +280,16 @@ export class EventDispatcher extends HashObject {
// }
}
}
return s
}
/**
* 移除对象中所有的侦听
* 移除对象中所有的侦听,返回自身
* @method removeAllEventListener
* @public
* @since 1.0.0
*/
public removeAllEventListener() {
public removeAllEventListener(): this {
let s = this;
for (let type in s.eventTypes) {
if (type.indexOf("onMouse") == 0) {
......@@ -305,6 +307,7 @@ export class EventDispatcher extends HashObject {
}
s.eventTypes1 = {};
s.eventTypes = {};
return s;
}
destroy(): void {
......
......@@ -31,7 +31,7 @@ export default class PanelCtrl {
this._parent = parent;
let bg = new Graphics();
bg.beginFill(0, 1);
bg.drawRect(0, 0, layers.stageWidth, layers.stageHeight);
bg.drawRect(0, layers.stageOffsetY - parent.y, layers.stageWidth, layers.stageHeight);
bg.endFill();
bg.visible = false;
this._parent.addChild(bg);
......
......@@ -33,13 +33,15 @@ class Layers extends Container {
this.addChild(this[arr[i]]);
}
//弹框要居中适配,加个
this.popupLayer.y = 0;
//初始化场景层级
SceneCtrl.instance.init(this.sceneLayer)
//初始化弹框层级
PanelCtrl.instance.init(this.popupLayer)
//弹框要居中适配,加个
this.popupLayer.y = 0;
}
......
{
"groups": [
{
"keys": "comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png",
"keys": "comCloseBtn.png,light.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common"
},
{
"keys": "fanhuishouye.png,gameOverPanelBg.png,quzhuanjifen.png,scoreLevel1.png,scoreLevel2.png,scoreLevel3.png,zailaiyiju.png",
"name": "gameOverPanel"
},
{
"keys": "bombBtn.png,ele1024.png,ele128.png,ele16.png,ele2.png,ele2048.png,ele256.png,ele32.png,ele4.png,ele512.png,ele64.png,ele8.png,exchangeBtn.png,filterBtn.png,playBg.png",
"name": "playScene"
},
{
"keys": "getPropBtn.png,propOutPanelBg.png",
"name": "propOutPanel"
},
{
"keys": "fangqi.png,huoqudaoju.png,propPanelBg.png",
"name": "propPanel"
},
{
"keys": "jixuchuangguan.png,quitPanelBg.png,tuichubenguan.png",
"name": "quitPanel"
},
{
"keys": "snake.png,startBtn.png",
"name": "startScene"
},
{
"keys": "jiaohuan.png,kaixinshouxia.png,libao.png,lvwang.png,t0.png,t1.png,t2.png,t3.png,t4.png,t5.png,t6.png,t7.png,t8.png,t9.png,taskCompletePanelBg.png,tx.png,zhadan.png",
"name": "taskCompletePanel"
},
{
"keys": "lingqujiangli.png,quguanzhu.png,qushoucang.png,quxiadan.png,quyaoqing.png,taskPanelBg.png,yiguanzhu.png,yilingqu.png",
"name": "taskPanel"
},
{
"keys": "jixuyouxi.png,n0.png,n1.png,n2.png,n3.png,n4.png,n5.png,n6.png,n7.png,n8.png,n9.png,unlock128.png,unlockMsg.png,unlockPanelBg.png",
"name": "unlockPanel"
}
]
}
\ No newline at end of file
......@@ -62,12 +62,13 @@ export class Main {
//隐藏加载中
if (document.getElementById("__loading__")) document.getElementById("__loading__").style.display = "none";
//打开开始场景
changeScene(PlayScene); return;
// changeScene(StartScene); return;
//获取数据,,必成功
showWaiting();
sendTbNet(TbNetName.getAppData, {}, (s, res) => {
Tool.globalData = res.data;
changeScene(PlayScene);
// changeScene(PlayScene);
changeScene(StartScene);
})
......
This diff is collapsed.
import { Sprite } from "../engine/2d/display";
import { RES } from "../module/RES";
import { GTool } from "../module/tools/GTool";
import { TEXT_ALIGN } from "../engine/2d/const";
import { TextField } from "../engine/2d/text";
import { Graphics } from "../engine/2d/graphics";
/**
* 定制,记录一些全局量和方法
......@@ -48,40 +51,69 @@ export class Tool {
sprite.y = y;
return sprite
}
/**
* 最大距离
*/
public static maxDistance: number = 1000;
//当前奖品的Icon图片,现在链接测试,注意需要更新
public static curPrizeIcon: string //= "//yun.duiba.com.cn/images/201607/73htz55ih9.jpg"
public static memberUrl: string;
public static endTime: number;
public static addText(
txt: string,
size: number,
color: string = "#000000",
align: TEXT_ALIGN = TEXT_ALIGN.CENTER,
textWidth: number = 0,
x: number = 0,
y: number = 0
) {
var text = new TextField();
text.fillColor = color;
text.size = size;
text.textWidth = textWidth;
text.textAlign = align;
text.x = x;
text.y = y;
text.text = txt;
return text
}
/**
* 已经过期
*/
public static hasExpired: boolean
/**
* 自己的分享shareId
* 左上角原点
* @param width
* @param height
* @param color
* @param alpha
* @param radius
* @param x
* @param y
*/
public static openId: string
public static addRect(
width: number,
height: number,
color: number = 0xff0000,
alpha: number = 1,
radius: number = 0,
x: number = 0,
y: number = 0,
) {
var g = new Graphics();
g.beginFill(color);
g.alpha = alpha;
if (!radius) {
g.drawRect(0, 0, width, height)
} else {
g.drawRoundedRect(0, 0, width, height, radius)
}
g.endFill();
g.position.set(x, y);
return g
}
//进页面需要从小程序获得的数据
public static globalData: {
joinNeedsCredits: number,
activityId: string,
nickName: string,
avatar: string,
shareId?: string,//分享者的
theme:string,//adult kid
theme: string,//adult kid
};
/**
* 分享者的信息
*/
public static shareUserInfo: {
"avatar": string,
"nickName": string
}
}
\ No newline at end of file
import { Sprite } from "../../engine/2d/display";
import { RES } from "../../module/RES";
import { Event } from "../../engine/2d/events";
/**
* 旋转光
*/
export class Light extends Sprite {
constructor() {
super();
this.texture = RES.getRes("light.png");
this.anchorTexture.set(0.5, 0.5);
this.addEventListener(Event.ENTER_FRAME, () => {
this.rotation += 1;
}, this)
}
}
\ No newline at end of file
import { sendTbNet, TbNetName } from "./TaoBaoNet";
import { Tool } from "./Tools";
import { GDispatcher } from "../engine/2d/events";
/**
*
* @param callback
* @param score
* @param grade
* @param isFinal 是否最终提交,默认是的
*/
export function submit(callback: (s: boolean, res?: any) => void, score: number, grade: number, id: string, isFinal: boolean = true) {
sendTbNet(
TbNetName.submit,
{
activityId: Tool.globalData.activityId,
grade: grade,
score: score,
type: isFinal ? 1 : 0,
playId: id
},
(s, res) => {
callback(s, res)
}
)
}
/**
* 获取道具数量
* 自动派发事件
* 暂时可能不需要加回调,需要时再说
*/
export function getTools() {
sendTbNet(
TbNetName.getTools,
{ actitvityId: Tool.globalData.activityId },
(s, res) => {
//如果成功就更新道具数量
if (s) GDispatcher.dispatchEvent("updateProp", res.data.bombCount, res.data.exchangeCount, res.data.netCount)
},
true
)
}
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
import { Light } from '../common/Light';
import { TextField } from '../../engine/2d/text';
import { TEXT_ALIGN } from '../../engine/2d/const';
import { sendTbNet, TbNetName } from '../TaoBaoNet';
import { showWaiting, hideWaiting, getCurrentScene } from '../../module/ctrls';
import { PlayScene } from '../scenes/playScene/PlayScene';
import { GDispatcher } from '../../engine/2d/events';
import Tween from '../../engine/tween/Tween';
import { Ease } from '../../engine/tween/Ease';
const levelDes = {
2: "33",
4: "11",
8: "11",
16: "22",
32: "22",
64: "22",
128: "22",
256: "22",
512: "22",
1024: "22",
2048: "22",
}
/**
* 游戏结束
*/
export class GameOverPanel extends Panel {
get groupNames() { return ["gameOverPanel"] }
closeBtn: Button;
returnBtn: Button;
againBtn: Button;
goEarnBtn: Button;
data: {
score: number;
playDuration: number;
grade: number;
credits?: number//获取的积分
creditsTimesToday?: number
}
initUi() {
//加光
this.addChild(new Light()).position.set(375, 735);
//背景
this.addChild(Tool.addSprite("gameOverPanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(612, 460);
this.addChild(this.closeBtn);
//分数
var scoreTxt = new TextField();
scoreTxt.fillColor = "#fada30";
scoreTxt.bold = true;
scoreTxt.size = 72;
scoreTxt.textWidth = 550;
scoreTxt.textAlign = TEXT_ALIGN.CENTER;
scoreTxt.x = 90;
scoreTxt.y = 660;
scoreTxt.text = this.data.score + "";
this.addChild(scoreTxt)
//获得积分文案,根据数据判断
if (this.data.credits) {
this.addChild(Tool.addText(
"获得" + this.data.credits + "积分(今日" + this.data.creditsTimesToday + "/3)",
24,
"#ddccfe",
TEXT_ALIGN.CENTER,
350,
200,
731
))
}
//印章
var t: string;
if (this.data.score >= 2000) {
t = "scoreLevel3"
} else if (this.data.score >= 1000) {
t = "scoreLevel2"
} else if (this.data.score >= 300) {
t = "scoreLevel1"
}
if (t) {
var yin = Sprite.from(t + ".png");
yin.alpha = 0;
yin.position.set(200, 600)
yin.scale.set(2, 2);
this.addChild(yin);
Tween.get(yin).to({ x: 40, y: 497, alpha: 1, scaleX: 1, scaleY: 1 }, 500, Ease.quadIn)
}
//时间
var timeTxt = new TextField();
timeTxt.fillColor = "#ebde69";
timeTxt.size = 28;
timeTxt.textWidth = 270;
timeTxt.textAlign = TEXT_ALIGN.CENTER;
timeTxt.x = 117;
timeTxt.y = 855;
timeTxt.text = date_format(this.data.playDuration);
this.addChild(timeTxt)
//最高解锁
var levelTxt = new TextField();
levelTxt.fillColor = "#ebde69";
levelTxt.size = 28;
levelTxt.textWidth = 118;
levelTxt.textAlign = TEXT_ALIGN.CENTER;
levelTxt.x = 450;
levelTxt.y = 855;
levelTxt.text = this.data.grade + "";
this.addChild(levelTxt)
//最高解锁形容词
var desTxt = new TextField();
desTxt.fillColor = "#b093ea";
desTxt.size = 18;
desTxt.textWidth = 118;
desTxt.textAlign = TEXT_ALIGN.CENTER;
desTxt.x = 450;
desTxt.y = 887;
desTxt.text = "(" + levelDes[this.data.grade] + ")";
this.addChild(desTxt);
//返回首页按钮
this.returnBtn = this.addChild(new Button(RES.getRes("fanhuishouye.png"))) as Button;
this.returnBtn.position.set(117, 959);
//再来一次按钮
this.againBtn = this.addChild(new Button(RES.getRes("zailaiyiju.png"))) as Button;
this.againBtn.position.set(383, 959);
this.againBtn.visible = false;
//去赚积分按钮
this.goEarnBtn = this.addChild(new Button(RES.getRes("quzhuanjifen.png"))) as Button;
this.goEarnBtn.position.set(383, 959);
this.goEarnBtn.visible = false;
//积分/次文案
var needCreditsTxt = this.addChild(Tool.addText(
"(" + Tool.globalData.joinNeedsCredits + "积分/次)",
24,
"#b093ea",
TEXT_ALIGN.CENTER,
233,
383,
1044
))
needCreditsTxt.visible = false;
//先获取积分,然后判断
sendTbNet(TbNetName.getCredits, { activityId: Tool.globalData.activityId }, (s, res) => {
//积分足够
if (s && res.data.credits && res.data.credits >= Tool.globalData.joinNeedsCredits) {
needCreditsTxt.visible = true;
this.againBtn.visible = true;
} else {
this.goEarnBtn.visible = true;
}
})
}
start() {
super.start();
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
this.onClick(this.returnBtn, this.onClick_closeBtn, this)
this.onClick(this.againBtn, this.onClick_againBtn, this)
this.onClick(this.goEarnBtn, this.onClick_goEarnBtn, this)
}
onClick_closeBtn() {
// this.hidePanel();
//回到首页
sendTbNet(TbNetName.navigateBack, { delta: 1 }, () => { })
}
onClick_againBtn() {
//发接口,重玩游戏 TODO
showWaiting();
sendTbNet(
TbNetName.startGame,
{ activityId: Tool.globalData.activityId, nickName: Tool.globalData.nickName },
(s, res: { data: { maxScore: number, unlockGrade: number, bombCount: number, exchangeCount: number, netCount: number } }) => {
hideWaiting();
this.hidePanel();
if (s) {
var data = res.data
var playScene: PlayScene = getCurrentScene();
// playScene.resetGame(res.unlockGrade)//代加参数,方法
//修改道具数量
GDispatcher.dispatchEvent("updateProp", data.bombCount, data.exchangeCount, data.netCount)
}
}
)
}
onClick_goEarnBtn() {
//链接待填
sendTbNet(TbNetName.navigateToOutside, { url: "" }, () => { })
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this);
this.removeClick(this.returnBtn, this.onClick_closeBtn, this);
this.removeClick(this.againBtn, this.onClick_againBtn, this);
this.removeClick(this.goEarnBtn, this.onClick_goEarnBtn, this);
}
}
//转换时分秒
//时分秒换算
function date_format(micro_second) {
// 总秒数
var second = Math.floor(micro_second / 1000);
// 天数
var day = Math.floor(second / 3600 / 24);
// 小时
var hr = Math.floor(second / 3600 % 24);
// 分钟
var min = Math.floor(second / 60 % 60);
// 秒
var sec = Math.floor(second % 60);
// return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
// return (hr + day * 24) + "小时" + min + "分" + sec + "秒";
var str = sec + "秒";
if (min) str = min + "分" + str;
if (hr + day * 24) str = (hr + day * 24) + "小时" + str;
return str
};
\ No newline at end of file
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
import { showPanel } from '../../module/ctrls';
import { TaskPanel } from './TaskPanel';
export class PropOutPanel extends Panel {
get groupNames() { return ["propOutPanel"] }
closeBtn: Button;
getPropBtn: Button;
initUi() {
//背景
this.addChild(Tool.addSprite("propOutPanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(627, 471);
this.addChild(this.closeBtn);
//获取道具按钮,弹出任务弹框
this.getPropBtn = new Button(RES.getRes("getPropBtn.png"));
this.getPropBtn.position.set(209, 749);
this.addChild(this.getPropBtn);
}
start(data) {
super.start();
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
this.onClick(this.getPropBtn, this.onClick_getPropBtn, this)
}
onClick_closeBtn() {
this.hidePanel();
}
onClick_getPropBtn() {
this.hidePanel();
showPanel(TaskPanel)
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this)
this.removeClick(this.getPropBtn, this.onClick_getPropBtn, this)
}
}
\ No newline at end of file
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
import { showPanel, showToast, getCurrentScene, showWaiting, hideWaiting } from '../../module/ctrls';
import { TaskPanel } from './TaskPanel';
import { GDispatcher } from '../../engine/2d/events';
import { TextField } from '../../engine/2d/text';
import { PlayScene } from '../scenes/playScene/PlayScene';
import { sendTbNet, TbNetName } from '../TaoBaoNet';
import { GameOverPanel } from './GameOverPanel';
import { submit } from '../commonNet';
/**
* 道具弹框,还没好
*/
export class PropPanel extends Panel {
get groupNames() { return ["propPanel"] }
closeBtn: Button;
quitBtn: Button;
getPropBtn: Button;
//炸弹
private bombCountTxt: TextField;
private _bombCount: number;
private bombArea: Graphics;
get bombCount() {
return this._bombCount;
}
set bombCount(value) {
this._bombCount = value;
this.bombCountTxt.text = value > 99 ? "99" : value + ""
}
//交换
private exchangeCountTxt: TextField;
private _exchangeCount: number;
private exchangeArea: Graphics;
get exchangeCount() {
return this._exchangeCount;
}
set exchangeCount(value) {
this._exchangeCount = value;
this.exchangeCountTxt.text = value > 99 ? "99" : value + ""
}
//滤网
private netCountTxt: TextField;
private _netCount: number;
private netArea: Graphics;
get netCount() {
return this._netCount;
}
set netCount(value) {
this._netCount = value;
this.netCountTxt.text = value > 99 ? "99" : value + ""
}
data: {
bombCount: number,
exchangeCount: number,
netCount: number,
grade: number,
score: number,
id: string;
}
initUi() {
//背景
this.addChild(Tool.addSprite("propPanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(613, 460);
this.addChild(this.closeBtn);
//放弃按钮
this.quitBtn = this.addChild(new Button(RES.getRes("fangqi.png")));
this.quitBtn.position.set(116, 926);
//获取道具按钮
this.getPropBtn = this.addChild(new Button(RES.getRes("huoqudaoju.png")))
this.getPropBtn.position.set(383, 926);
//文案
this.bombCountTxt = this.addChild(Tool.addText("", 28, "#ffffff", undefined, 70, 194, 728))
this.exchangeCountTxt = this.addChild(Tool.addText("", 28, "#ffffff", undefined, 70, 377, 728))
this.netCountTxt = this.addChild(Tool.addText("", 28, "#ffffff", undefined, 70, 556, 728))
//点击区域
this.bombArea = this.addChild(Tool.addRect(126, 142, undefined, 0, 0, 117, 717))
this.exchangeArea = this.addChild(Tool.addRect(126, 142, undefined, 0, 0, 296, 717))
this.netArea = this.addChild(Tool.addRect(126, 142, undefined, 0, 0, 476, 717))
}
start() {
super.start();
//需要添加事件,如果道具数量更新了,需要执行
GDispatcher.addEvent("updateProp", this.updateProp, this);
this.bombCount = this.data.bombCount;
this.exchangeCount = this.data.exchangeCount;
this.netCount = this.data.netCount;
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
this.onClick(this.quitBtn, this.onClick_closeBtn, this)
this.onClick(this.getPropBtn, this.onClick_getPropBtn, this)
this.onClick(this.bombArea, this.onClick_prop, this);
this.onClick(this.exchangeArea, this.onClick_prop, this);
this.onClick(this.netArea, this.onClick_prop, this);
}
onClick_closeBtn() {
// this.hidePanel();//提交完成再关闭,弹其他弹窗
//提交游戏
showWaiting();
submit((s, res) => {
hideWaiting();
if (s) {
this.hidePanel();
//显示结束弹框
showPanel(GameOverPanel, res.data)
}
}, this.data.score, this.data.grade, this.data.id)
}
onClick_getPropBtn() {
showPanel(TaskPanel)
}
updateProp(bombCount: number, exchangeCount: number, netCount: number) {
this.bombCount = bombCount;
this.exchangeCount = exchangeCount;
this.netCount = netCount;
}
onClick_prop(e: MouseEvent) {
let count: number, type: string;
if (e.target == this.bombArea) {
count = this.bombCount;
type = "onClick_bombBtn"
}
else if (e.target == this.exchangeArea) {
count = this.exchangeCount;
type = "onClick_exchangeBtn"
}
else if (e.target == this.netArea) {
count = this.netCount;
type = "onClick_filterBtn"
}
if (!count) {
showToast("暂无此道具,快去赚取道具吧")
return
}
this.hidePanel();
//执行道具的方法
getCurrentScene()[type]();
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this)
this.removeClick(this.quitBtn, this.onClick_closeBtn, this)
this.removeClick(this.getPropBtn, this.onClick_getPropBtn, this)
this.removeClick(this.bombArea, this.onClick_prop, this);
this.removeClick(this.exchangeArea, this.onClick_prop, this);
this.removeClick(this.netArea, this.onClick_prop, this);
GDispatcher.removeEvent("updateProp", this.updateProp, this)
}
}
\ No newline at end of file
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
import { submit } from '../commonNet';
import { showWaiting, hideWaiting, showPanel } from '../../module/ctrls';
import { GameOverPanel } from './GameOverPanel';
/**
* 弹框复制用
*/
export class QuitPanel extends Panel {
get groupNames() { return ["quitPanel"] }
closeBtn: Button;
data: {
grade: number,
score: number,
id: string//订单id
}
initUi() {
//背景
this.addChild(Tool.addSprite("quitPanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(630, 467);
this.addChild(this.closeBtn);
//继续闯关
this.addChild(new Button(RES.getRes("jixuchuangguan.png")))
.once(MouseEvent.CLICK, this.onClick_closeBtn, this)
.position.set(398, 750)
//退出本关,提交后,出结束弹框,
this.addChild(new Button(RES.getRes("tuichubenguan.png")))
.once(MouseEvent.CLICK, () => {
showWaiting();
//提交
submit((s, res) => {
hideWaiting();
if (!s) return
this.hidePanel();
//显示结束弹框
showPanel(GameOverPanel, res.data)
}, this.data.score, this.data.grade, this.data.id)
}, this)
.position.set(134, 750)
}
start(data) {
super.start();
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
}
onClick_closeBtn() {
this.hidePanel();
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this)
}
}
\ No newline at end of file
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
/**
* 任务完成,点击领取弹框,还没好
*/
export class TaskCompletePanel extends Panel {
get groupNames() { return ["taskCompletePanel"] }
closeBtn: Button;
initUi() {
//背景
this.addChild(Tool.addSprite("taskCompletePanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(630, 468);
this.addChild(this.closeBtn);
//开心收下
this.addChild(new Button(RES.getRes("kaixinshouxia.png")))
.once(MouseEvent.CLICK, this.onClick_closeBtn, this)
.position.set(212, 846)
//领奖内容,注意发接口刷新道具数量,更新场景道具数量
}
data: {
}
start(data) {
super.start();
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
}
onClick_closeBtn() {
this.hidePanel();
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this)
}
}
\ No newline at end of file
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
import { layers } from '../../module/views/layers';
import Tween from '../../engine/tween/Tween';
/**
* 任务弹框,还没好
*/
export class TaskPanel extends Panel {
get groupNames() { return ["taskPanel"] }
closeBtn: Button;
initUi() {
//底部适配,原先都是居中的,
this.y = (layers.stageHeight - 1624) / 2
//背景
this.addChild(Tool.addSprite("taskPanelBg.png")).position.set(0, 1624 - 1075);
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(681, 870);
this.addChild(this.closeBtn);
//四个按钮
}
//动画重写,从下往上
showAni() {
var oriY = this.y;
this.y += this.getLocalBounds().height;
Tween.get(this)
.to({ y: oriY }, 500)
}
start(data) {
super.start();
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
}
onClick_closeBtn() {
this.hidePanel();
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this)
}
}
\ No newline at end of file
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite, Container } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
import { Light } from '../common/Light';
import { BitmapText } from '../../engine/2d/text';
import { TEXT_ALIGN } from '../../engine/2d/const';
const foodData: {
[key: number]: { name: string, des: string }
} = {
8: { name: "啊是大", des: "自学成才" },
16: { name: "", des: "" },
32: { name: "", des: "" },
64: { name: "", des: "" },
128: { name: "良品铺子猪肉脯", des: "靖江特产独立小包装肉干网红休闲零食小吃" },
256: { name: "", des: "" },
512: { name: "", des: "" },
1024: { name: "", des: "" },
2048: { name: "", des: "" },
}
/**
* 解锁弹框
*/
export class UnlockPanel extends Panel {
get groupNames() { return ["unlockPanel"] }
closeBtn: Button;
data: {
grade: number
}
initUi() {
//加光
this.addChild(new Light()).position.set(375, 735);
//背景
this.addChild(Tool.addSprite("unlockPanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(614, 460);
this.addChild(this.closeBtn);
//继续游戏
this.addChild(new Button(RES.getRes("jixuyouxi.png")))
.once(MouseEvent.CLICK, this.onClick_closeBtn, this)
.position.set((750 - 341) / 2, 978)
//标题文案
this.addChild(new Title(this.data.grade))
//奖品图片 246;
this.addChild(new Sprite(RES.getRes("unlock" + this.data.grade + ".png")))
.position.set((750 - 246) / 2, 622)
//名字
this.addChild(Tool.addText(
foodData[this.data.grade].name,
28,
"#ffffff",
undefined,
560,
(750 - 560) / 2,
890
))
//描述
this.addChild(Tool.addText(
foodData[this.data.grade].des,
22,
"#dac5fc",
undefined,
560,
(750 - 560) / 2,
931
))
}
start(data) {
super.start();
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
}
onClick_closeBtn() {
this.hidePanel();
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this)
}
}
class Title extends Container {
grade: number
constructor(grade: number) {
super();
var msg = new Sprite(RES.getRes("unlockMsg.png"))
this.addChild(msg);
var textures = {}
for (var i = 0; i < 10; i++)textures[i] = RES.getRes("n" + i + ".png");
var num = new BitmapText(textures);
num.textAlign = TEXT_ALIGN.LEFT;
num.text = grade + "";
this.addChild(num);
var w = msg.width + num.width;
msg.position.set((750 - w) / 2, 548);
num.position.set(msg.x + msg.width, 548 + 4)
}
}
\ No newline at end of file
......@@ -9,29 +9,28 @@ import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
/**
* 奖品擦肩而过的弹框
* 弹框复制用
*/
export class PanelBase extends Panel {
get groupNames() { return ["common", "rulePanel"] }
bg
get groupNames() { return ["rulePanel"] }
closeBtn: Button;
/**
* 关闭之后的回调
*/
closeFun;
initUi() {
//背景
this.bg = this.addChild(Tool.addSprite("rulePanelBg.png", (750 - 600) / 2, 200));
this.addChild(Tool.addSprite("rulePanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(650, 380);
this.addChild(this.closeBtn);
}
data:{
}
start(data) {
super.start();
}
initEvents() {
......@@ -39,7 +38,7 @@ export class PanelBase extends Panel {
}
onClick_closeBtn() {
this.hidePanel()
this.hidePanel();
}
removeEvents() {
......
......@@ -25,20 +25,46 @@ import { AdjustmentFilter } from "../../engine/2d/filter/adjustment/AdjustmentFi
import { AdvancedBloomFilter } from "../../engine/2d/filter/advanced-bloom/AdvancedBloomFilter";
import { Scene } from "../../module/views/Scene";
import { RES } from "../../module/RES";
import { changeScene } from "../../module/ctrls";
import { changeScene, showPanel } from "../../module/ctrls";
import { layers } from "../../module/views/layers";
import { NineSlicePlane } from '../../engine/2d/mesh';
import { Rope } from '../../engine/2d/mesh/Rope';
import { GameOverPanel } from '../panels/GameOverPanel';
import { PropOutPanel } from '../panels/PropOutPanel';
import { TaskPanel } from '../panels/TaskPanel';
import { PropPanel } from '../panels/PropPanel';
import { QuitPanel } from '../panels/QuitPanel';
import { UnlockPanel } from '../panels/UnlockPanel';
import { TaskCompletePanel } from '../panels/TaskCompletePanel';
export class StartScene extends Scene {
get groupNames(): string[] { return ["startScene"] }
start() {
super.start();
// this.scaleX=0.5
// showPanel(PrizePanel)
showPanel(TaskPanel)
// showPanel(TaskCompletePanel)
// showPanel(UnlockPanel,{grade:128})
// showPanel(PropPanel, {
// bombCount: 22,
// exchangeCount: 22,
// netCount: 33,
// score: 22,
// grade: 1024,
// id:"223"
// })
// showPanel(QuitPanel, {
// score: 22,
// grade: 1024,
// id:"223"
// })
// showPanel(GameOverPanel, {
// score: 4444,
// playDuration: 956456,
// grade: 1024,
// credits: 20,
// creditsTimesToday: 1
// })
// setTimeout(() => {
// // console.log(this.stage)
// // this.stage.globalToLocal(new Point(10, 1))
......@@ -59,7 +85,7 @@ export class StartScene extends Scene {
// this.testDisplaceFilter()
// this.testEditableText()
// this.testNine();
this.testRope()
// this.testRope()
}
//初始化ui
initUi() {
......
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