Commit 2848e78e authored by XieChuanJin's avatar XieChuanJin

换皮完成

parent b812e83c
......@@ -31,7 +31,7 @@
<div id="game-container" style="line-height:0;font-size:0"></div>
<script src="//res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<!--script src="http://localhost:4002/debug/engine.js"></script-->
<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.d253f569148b2343d5d6cc212e95f8237d52be24.js"></script>
<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.a55406676ddead0c1728d886fa14378bbf82d873.js"></script>
<script src="app.js"></script>
<script>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -10,4 +10,8 @@ declare namespace engine {
interface Point {
length: number;
}
interface DisplayObject {
destroy(): void;
}
}
\ No newline at end of file
This diff is collapsed.
import { MConst } from "./MConst";
import { MUtils } from "./MUtils";
import { MTween } from "./MTween";
import { TextureMgr } from "./Mgr/TextureMgr";
import { PoolElement, Pool, PoolGroup } from "./Pool";
const BoomEffectDuration = 400;
const DefaultRingWidth = 672;
export default class BoomEffect {
constructor(position: engine.Point, parent: engine.Container, colorIndex: number, size: number) {
let range = MConst.DefaultBallWidth * 1.5 * size;
for (let i = 0; i <= 7; i++) {
const star = spritePool.spwan("star", colorIndex);
parent.addChild(star);
const randomMax = 0.5 + (size - 0.3125) / 2;
const scale = MUtils.random(randomMax - 0.64 * size, randomMax);
star.width = MConst.DefaultStarSize.width * scale;
star.height = MConst.DefaultStarSize.height * scale;
star.x = position.x;
star.y = position.y;
MTween.get(star)
.to({
x: position.x + MUtils.random(-1, 1) * range - star.width / 2,
y: position.y + MUtils.random(-1, 1) * range - star.height / 2,
alpha: 0
}, BoomEffectDuration, false)
.call(() => {
spritePool.recycle(star.poolKey, star);
});
}
//环
for (let i = 0; i <= 2; i++) {
let ring = spritePool.spwan("ring", colorIndex);
parent.addChild(ring);
ring.scaleX = ring.scaleY = 0.186 * (i + 1) * size;
ring.x = position.x - DefaultRingWidth / 2;
ring.y = position.y - DefaultRingWidth / 2;
ring.anchorX = (DefaultRingWidth / 2);
ring.anchorY = (DefaultRingWidth / 2);
let tween = MTween.get(ring)
.to({
scaleX: ring.scaleX * 1.4,
scaleY: ring.scaleY * 1.4,
alpha: 0
}, BoomEffectDuration + (i - 1) * BoomEffectDuration * 0.33, false)
if (i == 2) {
tween.call(() => {
spritePool.recycle(ring.poolKey, ring);
});
} else {
tween.call(() => {
spritePool.recycle(ring.poolKey, ring);
});
}
}
}
onElementInit() {
}
onElementRecycle() {
}
}
export class BoomEffectSprite extends engine.Sprite implements PoolElement {
constructor(type: "star" | "ring", colorIndex: number) {
super(TextureMgr.get(type, colorIndex));
}
poolKey: string;
onElementInit() {
this.alpha = 1;
this.visible = true;
}
onElementRecycle() {
this.visible = false;
}
}
/* class Ring extends BoomEffectSprite {
constructor(type: "star" | "ring", colorIndex: number) {
super(type, colorIndex);
this.anchorX = (DefaultRingWidth / 2);
this.anchorY = (DefaultRingWidth / 2);
}
} */
class SpritePool extends Pool<BoomEffectSprite> {
public spwan(type: "star" | "ring", colorIndex: number): BoomEffectSprite {
if (this.data.length > 0) {
const element = this.data.shift();
element.onElementInit();
return element;
} else {
return new BoomEffectSprite(type, colorIndex);
}
}
}
class SpritePoolGroup extends PoolGroup<BoomEffectSprite> {
public spwan(type: "star" | "ring", colorIndex: number) {
const key = type + colorIndex;
if (!this.data[key]) {
this.data[key] = new SpritePool();
}
const element = this.data[key].spwan(type, colorIndex);
element.poolKey = key;
return element;
}
}
const spritePool = new SpritePoolGroup();
/* class RingPool extends Pool<Ring> {
public spwan(color: number): Ring {
if (this.data.length > 0) {
const element = this.data.shift();
element.onElementInit();
return element;
} else {
return new Ring(color);
}
}
}
class RingPoolGroup extends PoolGroup<Ring> {
public spwan(color: number) {
const key = color.toString();
if (!this.data[key]) {
this.data[key] = new RingPool();
}
const element = this.data[key].spwan(color);
element.poolKey = key;
return element;
}
}
const ringPool = new RingPoolGroup(); */
/* class BoomEffectPool extends Pool<BoomEffect> {
public spwan(color: number, size: number): BoomEffect {
if (this.data.length > 0) {
const element = this.data.shift();
element.onElementInit();
return element;
} else {
return new BoomEffect(color, size);
}
}
}
class BoomEffectPoolGroup extends PoolGroup<BoomEffect> {
public spwan(color: number, size: number) {
const key = color.toString() + size.toString();
if (!this.data[key]) {
this.data[key] = new BoomEffectPool()
}
const element = this.data[key].spwan(color, size);
element.poolKey = key;
return element;
}
}
let boomEffectPool = new BoomEffectPoolGroup();
export default boomEffectPool; */
\ No newline at end of file
......@@ -4,19 +4,25 @@ import { MConst } from "./MConst";
import GameObject from "./GameObject";
import Collider, { CircleCollider, ColliderGroup, PointCollider } from "./Collider";
import Game from "./Game";
import { DataMgr } from "./Mgr/DataMgr";
import bulletPool from "./Pools/BulletPool";
import MTimer from "./MTimer";
const bulletSpeedValue = 20;
/**顾名思义 */
const frameCountThatBulletsMoveInX = 4;
export default class Bullet extends MoveObjcet implements PoolElement {
public power: number = 1;
constructor(context: Game) {
super(context);
this.addChild(new engine.Image(RES.getRes("bullet_png")));
this.anchorY = 0;
constructor() {
super();
this.addChild(new engine.Image(RES.getRes("09bdff41-2fe3-4298-ad3a-1d2eaf6af778")));
let collider = this.addComponent(PointCollider) as PointCollider;
collider.group = ColliderGroup.Bullet;
collider.setData(2, 0);
this.physics.velocity.y = -MConst.BulletSpeedValue;
this.physics.velocity.y = -bulletSpeedValue;
}
init(power: number) {
......@@ -35,7 +41,57 @@ export default class Bullet extends MoveObjcet implements PoolElement {
onCollisionEnter(other: Collider) {
if (other.group == ColliderGroup.Ball || other.group == ColliderGroup.Top) {
this.context._bulletPool.destroy(this);
bulletPool.recycle(this);
}
}
}
export class BulletGroup {
private moveDatas: { bullet: Bullet, frameOffset: number }[] = [];
public restFrameCountThatBulletsMoveInX: number = frameCountThatBulletsMoveInX;
constructor(position: engine.Point, rowBulletNum: number) {
for (let i = 0; i < rowBulletNum; i++) {
const bullet = bulletPool.spwan().init(Math.floor(DataMgr.game.powerScore / 100));
DataMgr.game.addGameObject(bullet, "Bullet");
bullet.x = position.x - bullet.width / 2;
bullet.y = position.y + bullet.height / 2;
this.moveDatas.push({
bullet: bullet,
frameOffset: ((i - (rowBulletNum - 1) / 2) * bullet.width) / frameCountThatBulletsMoveInX
});
}
HorizontalMoveMgr.instance.movingList.push(this);
}
public onUpdate() {
let data: { bullet: Bullet, frameOffset: number } = null;
for (let i = 0; i < this.moveDatas.length; i++) {
data = this.moveDatas[i];
data.bullet.x += data.frameOffset;
}
this.restFrameCountThatBulletsMoveInX--;
}
}
class HorizontalMoveMgr {
private static _instance: HorizontalMoveMgr = null;
public static get instance(): HorizontalMoveMgr {
if (!HorizontalMoveMgr._instance) {
const instance = new HorizontalMoveMgr();
HorizontalMoveMgr._instance = instance;
MTimer.onFrame("HorizontalMoveMgr", instance.onUpdate, instance); //单例注册回调
}
return HorizontalMoveMgr._instance;
}
public movingList: BulletGroup[] = [];
public onUpdate() {
for (let i = 0; i < this.movingList.length; i++) {
this.movingList[i].onUpdate();
}
this.movingList = this.movingList.filter(e => e.restFrameCountThatBulletsMoveInX > 0);
}
}
\ No newline at end of file
import GameObject from "./GameObject";
import Collider, { RectCollider, ColliderGroup } from "./Collider";
import { MConst } from "./MConst";
import Bullet from "./Bullet";
import MTweenMgr from "./MTween";
import Bullet, { BulletGroup } from "./Bullet";
import { MTween } from "./MTween";
import SoundMgr from "./SoundMgr";
import MTimer from "./MTimer";
import Game from "./Game";
import { DataMgr } from "./Mgr/DataMgr";
import bulletPool from "./Pools/BulletPool";
export default class Car extends GameObject {
private imgGun: engine.Image = null;
private imgParticel: engine.Image = null;
private imgParticel: engine.Sprite = null;
private fireTimer: number = null;
public touchWall: 1 | -1 | 0 = 0;
public onDied: () => void;
private isDied: boolean = false;
private fireParticleTimer = 0;
private invincibleDuration = 0;
constructor(context: Game) {
super(context);
this.x = 124;
this.y = 145;
this.createPart("car_shadow_png", 4.96, 138.69);
this.createPart("car_part_0_png", 12.5, 102.5);
this.imgGun = this.createPart("car_gun_png", 33.5, 120);
this.createPart("car_wheel_png", 0, 97.5);
this.imgParticel = this.createPart("car_particle_png", 15.98, 1.33);
// this.imgParticel.alpha = 0;
this.imgGun.anchorY = 100;
this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
/**每排子弹的个数 */
private rowBulletNum: number = 1;
private fireSpeed: number = MConst.BulletFireSpeed.min;
constructor() {
super();
// this.x = 124;
// this.y = 145;
let sprite = new engine.Sprite(RES.getRes("ddf5128e-be66-4c00-8505-e4167aac37bc"));
sprite.x = 0;
sprite.y = 16;
this.addChild(sprite);
/* this.createPart("30fd41be-d702-4511-93d8-5f4609ea4c7d", 4.96, 138.69);
this.createPart("6211fb97-ba4a-4b79-b178-09dcf63c16d4", 12.5, 102.5);
this.imgGun = this.createPart("fbd26824-9f87-4784-b825-1d824de97023", 33.5, 20);
this.createPart("83144d98-b464-48d2-95ac-5b189f134ba7", 0, 97.5);
*/
let particle = new engine.Sprite(RES.getRes("d8daa113-0d75-4139-9e81-c54b7522c890"));
particle.x = 31;
particle.y = 0;
this.addChild(particle);
this.imgParticel = particle;
MTimer.onFrame("Car", this.onUpdate, this);
let collider = this.addComponent<RectCollider>(RectCollider);
collider.setData(29, 20, 63, 150);
collider.setData(41, 13, 65, 129);
collider.group = ColliderGroup.Car;
this.addEventListener(engine.Event.REMOVED_FROM_STAGE, this.onDestroy, this);
}
private createPart(source: string, x: number, y: number) {
/* private createPart(source: string, x: number, y: number) {
let bitmap = new engine.Image(RES.getRes(source) as engine.Texture);
bitmap.x = x;
bitmap.y = y;
this.addChild(bitmap);
return bitmap;
}
} */
private fire() {
// return;
SoundMgr.instance.playEffect("shoot_mp3");
// let column = this.context.fireBulletNumConfig[this.fireBulletNumConfigIndex];
// this.fireBulletNumConfigIndex = this.fireBulletNumConfigIndex == 0 ? 1 : 0; //0/1交替
const column = this.context._fireBulletNumConfig;
const numb = MConst.BulletDisperseFrameNum;
let bullets: Bullet[] = [];
for (let i = 0; i < column; i++) {
const bullet = this.context._bulletPool.create(this.context).init(Math.floor(this.context._PowerScore / 100));
bullet.posY = this.posY - this.height + 26;
bullet.posX = this.posX;
let offsetX = (i - (column - 1) / 2) * MConst.BulletWidth;
bullet.physics.velocity.x = offsetX / numb;
/* MTweenMgr.instance.get(bullet).wait(MConst.BulletDisperseFrameNum, true).call(() => {
bullet.physics.velocity.x = 0;
}); */
bullets.push(bullet);
}
MTimer.set(numb, () => {
for (let i of bullets) {
i.physics.velocity.x = 0;
}
});
new BulletGroup(new engine.Point(this.x + this.width / 2, this.y), this.rowBulletNum);
}
private die() {
return;
if (this.isDied) return;
this.isDied = true;
if (this.invincibleDuration > 0) return;
......@@ -104,7 +97,7 @@ export default class Car extends GameObject {
}
private onceBlink() {
MTweenMgr.instance.get(this)
MTween.get(this)
.to({ alpha: 0 }, 1, true)
.wait(2)
.to({ alpha: 1 }, 1, true)
......@@ -114,12 +107,12 @@ export default class Car extends GameObject {
revive() {
this.invincibleDuration = MConst.ReviveInvincibleDuration * 1000;
MTweenMgr.instance.removeTweens(this);
MTween.removeTweens(this);
this.onceBlink();
MTimer.set(MConst.ReviveInvincibleDuration * 60, () => {
MTimer.setFrameTimer(MConst.ReviveInvincibleDuration * 60, () => {
//无敌结束
this.alpha = 1;
MTweenMgr.instance.removeTweens(this);
MTween.removeTweens(this);
});
}
......@@ -129,7 +122,6 @@ export default class Car extends GameObject {
} else if (this.touchWall == -1 && deltaX >= 0) {
return;
}
this.x += deltaX;
}
......@@ -139,30 +131,40 @@ export default class Car extends GameObject {
}
}
private frameTimer = 0;
private onEnterFrame() {
if (this.context.pause) return;
private onUpdate() {
if (DataMgr.game.pause) return;
const score = DataMgr.game.bulletScore;
//更新开火速度
if (score <= 20) {
const max = MConst.BulletFireSpeed.max;
const min = MConst.BulletFireSpeed.min;
this.fireSpeed = min + (max - min) * (score / 20);
} else {
this.fireSpeed = MConst.BulletFireSpeed.max;
}
//更新子弹排数
this.rowBulletNum = Math.ceil((Math.clamp(score, 15, 140) / 2) / 10);
//无敌计时器流逝
if (this.invincibleDuration > 0) {
this.invincibleDuration -= MTimer.deltaTime;
}
//开火计时流逝
this.fireTimer += 1 * MTimer.dtFactor;
if (this.fireTimer >= 60 / this.context._fireSpeed) {
if (this.fireTimer >= 60 / this.fireSpeed) {
this.fire();
this.fireTimer = 0;
}
if (this.frameTimer % 3 == 0) {
if (this.fireParticleTimer % 3 == 0) {
this.imgParticel.visible = !this.imgParticel.visible;
}
this.frameTimer++;
this.fireParticleTimer++;
}
onDestroy() {
this.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
MTweenMgr.instance.removeTweens(this);
MTween.removeTweens(this);
}
}
\ No newline at end of file
......@@ -71,8 +71,8 @@ export class CircleCollider extends Collider {
y: 0
};
getWorldPosition(out: number[]) {
out[0] = this.owner.x - this.owner.anchorX + this.center[0];
out[1] = this.owner.y - this.owner.anchorY + this.center[1];
out[0] = this.owner.x + this.center[0];
out[1] = this.owner.y + this.center[1];
}
}
......@@ -96,8 +96,8 @@ export class RectCollider extends Collider {
return [this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2];
}
getWorldPosition(out: number[]) {
out[0] = this.owner.x - this.owner.anchorX + this.rect.left;
out[1] = this.owner.y - this.owner.anchorY + this.rect.top;
out[0] = this.owner.x + this.rect.left;
out[1] = this.owner.y + this.rect.top;
}
}
......@@ -137,7 +137,7 @@ export enum ColliderGroup {
}
export enum ColliderType {
Circle,
Rect,
Point
Circle = 0,
Rect = 1,
Point = 2
}
/* type AltaData = {
key: string,
frameRate: number,
frames: {
x: number, //x,y,w,h为图集上的切图位置数据
y: number,
w: number,
h: number
}[]
} */
interface Frame {
x: number,
y: number,
texture: engine.Texture
}
export default class FrameAnimation extends engine.Container {
private static caches: {
[key: string]: {
frameCount: number,
frameRate: number,
frames: Frame[]
}
} = {};
public static loadRes(texture: engine.Texture, egretData: any) {
let name: string = null;
const mc = egretData.mc;
for (let key in mc) { name = key; break; }
if (!FrameAnimation.caches[name]) {
let altaData = {};
for (let i in egretData.res) {
altaData[name + "_" + i] = egretData.res[i];
}
engine.createTextureSheet(texture.baseTexture, altaData);
let frames: Frame[] = [];
const framesData = mc[name].frames;
for (let i in framesData) {
frames[i] = {
x: framesData[i].x,
y: framesData[i].y,
texture: RES.getRes(name + "_" + framesData[i].res)
}
}
FrameAnimation.caches[name] = {
frameRate: mc[name].frameRate,
frameCount: Object.keys(altaData).length,
frames: frames
}
}
}
private static playingAnimations: FrameAnimation[] = [];
public static onUpdate() {
const list = FrameAnimation.playingAnimations;
for (let i = 0; i < list.length; i++) {
list[i].onUpdate();
}
}
private frames: Frame[] = [];
private frameCount: number = 0;
public curPos: number = 0;
private frameTimer: number = 0;
private frameRate: number = 60;
private sprite: engine.Sprite = new engine.Sprite;
constructor(key: string) {
super();
if (!FrameAnimation.caches[key]) {
console.error("unloaded animation:" + key);
return;
}
/* for (let i = 0; i < FrameAnimation.caches[key].frameCount; i++) {
let frame = engine.Texture.from(key + "_" + i);
if (frame) {
this.frames.push(frame);
} else {
console.error(`can not find frame ${i} of ${key}`);
return;
}
} */
this.frames = FrameAnimation.caches[key].frames;
this.frameCount = Object.keys(this.frames).length;
this.frameRate = FrameAnimation.caches[key].frameRate;
this.addChild(this.sprite);
}
onUpdate() {
if (this.frameTimer >= 60 / this.frameRate) {
if (this.curPos >= this.frameCount) {
this.onCompleted && this.onCompleted();
FrameAnimation.playingAnimations.splice(FrameAnimation.playingAnimations.indexOf(this), 1);
} else {
const frameData = this.frames[this.curPos];
this.sprite.texture = frameData.texture;
this.sprite.x = frameData.x;
this.sprite.y = frameData.y;
}
this.curPos++;
this.frameTimer = 0;
} else {
this.frameTimer++;
}
}
play() {
FrameAnimation.playingAnimations.push(this);
}
onCompleted: () => void;
}
\ No newline at end of file
export default class SpriteFontLabel extends engine.Container {
public set text(v: string) {
if (typeof v != "string") return;
if (v != this._text) {
this._text = v;
this.onDraw();
}
}
public get text() {
return this._text;
}
private _text: string = "";
public font: SpriteFont = null;
private sprites: engine.Sprite[] = [];
constructor(font: SpriteFont, text?: string) {
super();
this.font = font;
this.text = text;
}
private onDraw() {
if (!this.font) {
console.error("font is null");
return;
}
let sprite: engine.Sprite = null;
let tex: engine.Texture = null;
let char: string = null;
let curX: number = 0;
for (let i = 0; i < this._text.length; i++) {
char = this._text[i];
tex = this.font.getWord(char);
sprite = this.sprites[i];
if (tex) {
if (!sprite) {
sprite = new engine.Sprite();
this.addChild(sprite);
this.sprites.push(sprite);
}
sprite.texture = tex;
sprite.x = curX;
curX += sprite.width;
} else {
sprite.texture = null;
console.warn("con not resolve char:" + char);
}
}
if (this.sprites.length > this._text.length) {
//删除多余的sprite
let rest = this.sprites.slice(this._text.length);
for (let i of rest) {
i.destroy();
}
this.sprites = this.sprites.slice(0, this._text.length);
}
}
}
const fontCaches: {
[name: string]: {
[char: string]: engine.Texture
}
} = {}
type SpriteFontConfig = {
name: string,
textures: {
[char: string]: {
x: number, //x,y,w,h为图集上的切图位置数据
y: number,
w: number,
h: number,
ox: number, //ox,oy为偏移数据,trim裁剪的数据,在orig上的偏移{x:0,y:0,width:200,height:200}
oy: number,
sw: number, //sw,sh为原始宽高
sh: number,
}
}
}
export class SpriteFont {
public static load(texture: engine.Texture, config: SpriteFontConfig) {
if (!fontCaches[config.name]) {
let font: {
[char: string]: engine.Texture
} = {};
let altaData = {};
let chars = Object.keys(config.textures);
for (let char of chars) {
altaData[config.name + "_" + char] = config.textures[char];
}
engine.createTextureSheet(texture.baseTexture, altaData);
for (let char of chars) {
font[char] = RES.getRes(config.name + "_" + char);
}
fontCaches[config.name] = font;
}
}
private words: {
[char: string]: engine.Texture
} = null;
constructor(name: string) {
if (fontCaches[name]) {
this.words = fontCaches[name];
} else {
console.error("unloaded font:" + name);
}
}
getWord(char: string) {
return this.words[char];
}
}
\ No newline at end of file
import MoveObjcet from "./MoveObject";
import { MConfigs } from "./MConfigs";
import Collider, { ColliderGroup, PointCollider } from "./Collider";
import MTweenMgr from "./MTween";
import { MTween } from "./MTween";
import SoundMgr from "./SoundMgr";
import DropBlinkMgr from "./DropBlinkMgr";
import Game from "./Game";
export default class Drop extends MoveObjcet {
private type: string = null;
import { PoolElement } from "./Pool";
import dropPool from "./Pools/DropPool";
import { DataMgr } from "./Mgr/DataMgr";
import DropBlinkMgr from "./Mgr/DropBlinkMgr";
const dropImgNames = [
"f7221f86-f376-40ce-b0e8-f7ea573ec780",
"c9dbd728-1844-4910-b1ef-e84ce10dc422",
"41182131-7050-4b95-9dce-45275b70738d",
"17d8e000-b290-4972-bcab-cb819a6cf51b",
"3f7faebf-64da-44a4-8152-0c35fcc29fe5"
];
export default class Drop extends MoveObjcet implements PoolElement {
private type: "bullet" | "power" = null;
private label: engine.Label = null;
public bitmap: engine.Image = null;
private scoreValue: number = null;
private collider: PointCollider = null;
private isGround: boolean = false;
private stayGroundCount = 0;
private id: number = null;
constructor(context: Game) {
super(context);
constructor(id: number) {
super();
this.id = id;
//图像
let bitmap = new engine.Image();
this.addChild(bitmap);
......@@ -29,26 +42,17 @@ export default class Drop extends MoveObjcet {
this.label = label;
this.collider = this.addComponent<PointCollider>(PointCollider);
this.collider.group = ColliderGroup.Drop;
}
init(id: number) {
let config: {
type: string,
value: number,
textColor: number,
fileIndex: string
} = MConfigs.drop[id];
const config = MConfigs.drop[id];
this.type = config.type;
this.scoreValue = config.value;
this.physics.acceleration.y = 0.3;
let texture = RES.getRes(`drop_${config.type}_${config.fileIndex}_png`) as engine.Texture;
let texture = RES.getRes(dropImgNames[id]) as engine.Texture;
this.bitmap.texture = texture;
let str = "+" + config.value;
if (config.type == "power") str = str + "%";
let label = this.label;
label.text = str;
label.fillColor = config.textColor;
label.visible = false;
......@@ -56,7 +60,6 @@ export default class Drop extends MoveObjcet {
label.y = texture.height / 2 - label.height / 2;
this.collider.setData(texture.width / 2, texture.height / 2);
return this;
}
private eated() {
......@@ -69,16 +72,17 @@ export default class Drop extends MoveObjcet {
this.getComponent(PointCollider).enabled = false;
this.label.visible = true;
if (this.type == "bullet") {
this.context._BulletScore += this.scoreValue;
DataMgr.game._BulletScore += this.scoreValue;
} else if (this.type == "power") {
this.context._PowerScore += this.scoreValue;
DataMgr.game._PowerScore += this.scoreValue;
}
MTweenMgr.instance.removeTweens(this);
MTweenMgr.instance.get(this)
MTween.removeTweens(this);
MTween.get(this)
.to({ y: this.y - 200, alpha: 0 }, 1000, false)
.call(() => {
this.context._dropPool.destroy(this);
dropPool.recycle(this.id.toString(), this);
MTween.removeTweens(this);
});
}
......@@ -121,21 +125,18 @@ export default class Drop extends MoveObjcet {
}
}
/* destroy() {
DropBlinkMgr.instance.remove(this);
super.destroy();
} */
/* onElementInit() {
this.alpha = 1;
onElementInit() {
this.visible = true;
this.stayGroundCount = 0;
this.isGround = false;
this.enableAllComponents();
this.label.visible = false;
this.physics.acceleration.y = 0.3;
}
onElementRecycle() {
this.alpha = 1;
this.visible = false;
this.disableAllComponents();
} */
}
}
\ No newline at end of file
import { MUtils } from "./MUtils";
import BoomEffect from "./BoomEffect";
import FrameAnimation from "./Component/FrameAnimation";
import { Pool, PoolGroup, PoolElement } from "./Pool";
import SpBoomEffect from "./SpBoomEffect";
import spBoomEffectPool from "./SpBoomEffect";
export namespace EffectMgr {
let effectLayer: engine.Container = null;
let layers: engine.Container[] = [];
export function init(effectLayer: engine.Container) {
this.effectLayer = effectLayer;
layers[0] = new engine.Container();
layers[1] = new engine.Container();
effectLayer.addChild(layers[0]);
effectLayer.addChild(layers[1]);
}
export function playBoomEffect(position: engine.Point, size: number) {
const colorIndex = MUtils.randomInt(0, 5);
// new BoomEffect(position, layers[1], colorIndex, size);
let effect = spBoomEffectPool.spwan(MUtils.randomInt(0, 3), size);
layers[1].addChild(effect);
effect.position = position;
}
export function createAnimation(key: string): Animation {
let clip = animationPool.spwan(key);
layers[0].addChild(clip);
clip.onCompleted = () => {
animationPool.recycle(key, clip);
}
return clip;
}
}
class Animation extends FrameAnimation implements PoolElement {
onElementInit() {
this.visible = true;
this.curPos = 0;
}
onElementRecycle() {
this.visible = false;
}
}
class AnimationPool extends Pool<Animation> {
public spwan(key: string): Animation {
if (this.data.length > 0) {
const element = this.data.shift();
element.onElementInit();
return element;
} else {
return new Animation(key);
}
}
}
class AnimationPoolGroup extends PoolGroup<Animation> {
public spwan(key: string) {
if (!this.data[key]) {
this.data[key] = new AnimationPool() as Pool<Animation>;
}
const element = this.data[key].spwan(key);
return element;
}
}
const animationPool = new AnimationPoolGroup();
......@@ -34,8 +34,8 @@ export function clearShareImg() {
export function getBallScore(bulletScore: number, powerScore: number, colorIndex: number): any {
let getScoreFromRange = ([a, b]) => {
a = Math.ceil(a * MConfigs.difficultyFactor);
b = Math.ceil(b) * MConfigs.difficultyFactor;
a = Math.ceil(a * 0.1);
b = Math.ceil(b * 0.1);
let n = Math.abs(b - a) + 1;
n = Math.floor(n / 6);
const m = [];
......
This diff is collapsed.
import GameComponent from "./GameComponent";
import { MUtils } from "./MUtils";
import Collider from "./Collider";
import Game from "./Game";
export default class GameObject extends engine.Container {
public name: string = "";
private _position: engine.Point = new engine.Point();
public get position() {
this._position.x = this.x;
this._position.y = this.y;
return this._position;
}
public addComponent<T extends GameComponent>(cls: any): T {
if (this.getComponent(cls) != null) {
console.error("component is existent");
......@@ -44,49 +36,17 @@ export default class GameObject extends engine.Container {
}
private componentList: GameComponent[] = [];
protected context: Game = null;
constructor(context?: Game) {
constructor() {
super();
this.anchorX = 0.5;
this.anchorY = 0.5;
this.context = context;
this.touchEnabled = false;
this.touchChildren = false;
this.addEventListener(engine.Event.REMOVED_FROM_STAGE, this.disableAllComponents, this);
}
/**锚点X轴 */
public get anchorX(): number {
return this._anchorX;
}
public set anchorX(v: number) {
this._anchorX = Math.clamp(v, 0, 1);
// this.addEventListener(engine.Event.REMOVED_FROM_STAGE, this.disableAllComponents, this);
this.mouseEnabled = false;
this.mouseChildren = false;
}
private _anchorX: number = 0;
/**锚点Y轴 */
public get anchorY(): number {
return this._anchorY;
}
public set anchorY(v: number) {
this._anchorY = Math.clamp(v, 0, 1);
}
private _anchorY: number = 0;
public get posX(): number {
return this.x + this.width * this.scaleX * this.anchorX;
}
public set posX(v: number) {
this.x = v - this.width * this.scaleX * this.anchorX;
}
public get posY(): number {
return this.y + this.height * this.scaleY * this.anchorY;
}
public set posY(v: number) {
this.y = v - this.height * this.scaleY * this.anchorY;
/**销毁时禁用所有组件 */
destroy() {
super.destroy();
this.disableAllComponents();
}
protected disableAllComponents() {
......
import { MConfigs } from "./MConfigs";
export default class GuideMask extends engine.Container {
constructor(index: number, x: number, y: number) {
super();
const config = MConfigs.guide[index];
let bg = new engine.Shape();
bg.beginFill(0x000000);
bg.drawRect(0, 0, 750, 1624);
bg.endFill();
bg.alpha = 0.7;
let texture = RES.getRes(config.mask);
let bitmap = new engine.Sprite(texture);
bitmap.x = x - texture.width / 2;
bitmap.y = y - texture.height / 2;
//TODO
/* let container: engine.Container = new engine.Container();
container.addChild(bg);
container.addChild(bitmap);
bitmap.blendMode = engine.BlendMode.ERASE;
let renderTexture: engine.RenderTexture = new engine.RenderTexture();
renderTexture.drawToTexture(container);
let blendBitmap = new engine.Bitmap(renderTexture);
this.addChild(blendBitmap); */
let offsetToMask = config.text.offsetToMask;
let label = new engine.Label();
label.text = config.text.str;
label.size = 24;
label.x = offsetToMask.x + bitmap.x;
label.y = offsetToMask.y + bitmap.y;
this.addChild(label);
//TODO:拿到最新的尺寸
// label.validateSize();
if (label.x < 0) {
label.x = 0;
} else if (label.x + label.width > 750) {
label.x = 750 - label.width;
}
this.addEventListener(engine.MouseEvent.MOUSE_DOWN, () => {
this.onClick && this.onClick();
}, this);
}
onClick: () => void;
}
\ No newline at end of file
import PoolMgr from "./PoolMgr";
import Ball from "./Ball";
import PhycicsSystem from "./PhycicsSystem";
import MTweenMgr from "./MTween";
import SoundMgr from "./SoundMgr";
import { MConfigs } from "./MConfigs";
import GuideMask from "./GuideMask";
import SceneCtrl from "./MSceneCtrl";
import { ShootPlanet } from "./ShootPlanet";
export default class GameMgr {
private static _instance: GameMgr = null;
public static get instance(): GameMgr {
if (!this._instance) {
this._instance = new GameMgr();
export default class GuideMgr {
private static _instance: GuideMgr = null;
public static get instance(): GuideMgr {
if (!GuideMgr._instance) {
GuideMgr._instance = new GuideMgr();
}
return this._instance;
return GuideMgr._instance;
}
public t: number = 0;
public dropNum: number = 0;
private mainScene: MainScene = null;
init(mainScene: MainScene) {
private mainScene: ShootPlanet = null;
init(mainScene: ShootPlanet) {
this.mainScene = mainScene;
}
......@@ -49,7 +45,7 @@ export default class GameMgr {
this.guideFlag = false;
}
};
SceneCtrl.instance.parent.addChild(this.currentGuideMask);
this.mainScene.addChild(this.currentGuideMask);
}
public minEnableCaptchaScore: number = null;
......
export const NumFontData = {
name: "num_font",
textures: {
".": {
"x": 3,
"y": 215,
"w": 16,
"h": 17,
"ox": 7,
"oy": 49,
"sw": 29,
"sh": 66
},
"k": {
"x": 155,
"y": 3,
"w": 42,
"h": 65,
"ox": 6,
"oy": 0,
"sw": 48,
"sh": 66
},
"0": {
"x": 3,
"y": 144,
"w": 44,
"h": 65,
"ox": 2,
"oy": 1,
"sw": 48,
"sh": 66
},
"1": {
"x": 145,
"y": 74,
"w": 27,
"h": 65,
"ox": 7,
"oy": 0,
"sw": 48,
"sh": 66
},
"2": {
"x": 53,
"y": 74,
"w": 41,
"h": 64,
"ox": 3,
"oy": 1,
"sw": 48,
"sh": 66
},
"3": {
"x": 100,
"y": 74,
"w": 39,
"h": 65,
"ox": 5,
"oy": 1,
"sw": 48,
"sh": 66
},
"4": {
"x": 3,
"y": 3,
"w": 48,
"h": 64,
"ox": 0,
"oy": 1,
"sw": 48,
"sh": 66
},
"5": {
"x": 53,
"y": 144,
"w": 39,
"h": 65,
"ox": 5,
"oy": 1,
"sw": 48,
"sh": 66
},
"6": {
"x": 106,
"y": 3,
"w": 43,
"h": 65,
"ox": 3,
"oy": 1,
"sw": 48,
"sh": 66
},
"7": {
"x": 203,
"y": 3,
"w": 42,
"h": 64,
"ox": 3,
"oy": 1,
"sw": 48,
"sh": 66
},
"8": {
"x": 3,
"y": 73,
"w": 44,
"h": 65,
"ox": 2,
"oy": 1,
"sw": 48,
"sh": 66
},
"9": {
"x": 57,
"y": 3,
"w": 43,
"h": 65,
"ox": 2,
"oy": 1,
"sw": 48,
"sh": 66
}
}
}
export const DuangAltaData = {
"mc": {
"duang": {
"frameRate": 24,
"events": [],
"frames": [
{
"res": "3950AA49",
"x": 64,
"y": 46
},
{
"res": "86D16089",
"x": 27,
"y": 29
},
{
"res": "4B78217C",
"x": 13,
"y": 21
},
{
"res": "1B30AC5E",
"x": 9,
"y": 19
},
{
"res": "4C28F4CC",
"x": 177,
"y": 47
}
]
}
},
"res": {
"4B78217C": {
"x": 3,
"y": 60,
"w": 171,
"h": 46
},
"86D16089": {
"x": 3,
"y": 112,
"w": 144,
"h": 36
},
"4C28F4CC": {
"x": 189,
"y": 3,
"w": 14,
"h": 24
},
"3950AA49": {
"x": 3,
"y": 154,
"w": 80,
"h": 16
},
"1B30AC5E": {
"x": 3,
"y": 3,
"w": 180,
"h": 51
}
}
}
export const BoomAnimationData = {
"mc": {
"boom": {
"frameRate": 60,
"events": [
],
"frames": [
{
"res": "1ECDAB2E",
"x": 109,
"y": 109
},
{
"res": "7D1C3EA6",
"x": 104,
"y": 104
},
{
"res": "32FD22BF",
"x": 99,
"y": 99
},
{
"res": "8D21D7FD",
"x": 94,
"y": 94
},
{
"res": "AA99D248",
"x": 89,
"y": 89
},
{
"res": "EB300D3B",
"x": 84,
"y": 84
},
{
"res": "2D80AF70",
"x": 79,
"y": 79
},
{
"res": "D5989DA4",
"x": 74,
"y": 74
},
{
"res": "F357A8ED",
"x": 69,
"y": 69
},
{
"res": "84EE6F80",
"x": 64,
"y": 64
},
{
"res": "49BA3EE3",
"x": 59,
"y": 59
},
{
"res": "1F12115",
"x": 54,
"y": 54
},
{
"res": "DD77F7EA",
"x": 49,
"y": 49
},
{
"res": "8587C4D",
"x": 44,
"y": 44
},
{
"res": "9C93A4AF",
"x": 39,
"y": 39
},
{
"res": "9B8ABD91",
"x": 34,
"y": 34
}
]
}
},
"res": {
"F357A8ED": { "x": 1501, "y": 1, "w": 458, "h": 458 },
"8D21D7FD": { "x": 1389, "y": 481, "w": 407, "h": 407 },
"DD77F7EA": { "x": 521, "y": 1, "w": 498, "h": 498 },
"84EE6F80": { "x": 1, "y": 1521, "w": 468, "h": 468 },
"32FD22BF": { "x": 920, "y": 1389, "w": 397, "h": 397 },
"7D1C3EA6": { "x": 1389, "y": 890, "w": 387, "h": 387 },
"EB300D3B": { "x": 491, "y": 1389, "w": 427, "h": 427 },
"49BA3EE3": { "x": 1021, "y": 1, "w": 478, "h": 478 },
"9C93A4AF": { "x": 1, "y": 1, "w": 518, "h": 518 },
"1ECDAB2E": { "x": 1319, "y": 1279, "w": 377, "h": 377 },
"2D80AF70": { "x": 511, "y": 950, "w": 437, "h": 437 },
"1F12115": { "x": 1, "y": 1031, "w": 488, "h": 488 },
"8587C4D": { "x": 1, "y": 521, "w": 508, "h": 508 },
"D5989DA4": { "x": 521, "y": 501, "w": 447, "h": 447 },
"AA99D248": { "x": 970, "y": 501, "w": 417, "h": 417 },
"9B8ABD91": { "x": 1, "y": 1991, "w": 5, "h": 5 }
}
}
\ No newline at end of file
......@@ -12,7 +12,14 @@ export namespace MConfigs {
export const appId = "123";
export const size = [0.3125, 0.5357, 0.7321, 1];
export const drop = {
export const drop: {
[key: number]: {
type: "bullet" | "power",
value: number,
textColor: number,
fileIndex: string
}
} = {
0: {
type: "bullet",
value: 1,
......@@ -124,13 +131,13 @@ export namespace MConfigs {
}
}
export const boomEffectColor = [
/* export const boomEffectColor = [
0xe41014,
0xff9600,
0x0090ff,
0x8aff00,
0xffe720
]
] */
/**倒计时秒数 */
export const countDown = 300;
......@@ -228,9 +235,9 @@ export namespace MConfigs {
url: "http://activity-2.m.duiba.com.cn/customShare/share?id=3651"
}
export const toAppUrl = "http://www.baidu.com"
export const toAppUrl = "http://www.baidu.com";
export const wxMoreUrl="http://www.baidu.com"
export const wxMoreUrl = "http://www.baidu.com";
}
......
export namespace MConst {
export const MaxColorIndex = 5;
export const DesignResolution = {
x: 750,
y: 1624
width: 750,
height: 1624
};
export const GroundLine = 1110;
export const BulletSpeedValue = 20;
export const BulletFireSpeed = {
min: 10,
max: 20
......@@ -20,15 +19,13 @@ export namespace MConst {
offset: 0.5
}
export const BallRotateSpeed = 0.7;
export const BulletWidth = 14;
export const BulletDisperseFrameNum = 4;
// export const BulletWidth = 14;
export const BallInitPosY = 1206 * 0.25;
export const CreateBallInterval = 1000;
export const ReviveCardId = "sp_1";
export const ConstantSubmitScoreNum = 30000;
export const DefaultBallWidth = 224;
export const DefaultRingWidth = 672 * 0.744;
export const DefaultStarSize = {
width: 76 * 0.744,
height: 72 * 0.744
......
interface MEventData<T> {
callback: T,
thisObj: any,
bindFunc?: any
}
export default class MEvent<T extends Function>{
private list: MEventData<T>[] = [];
private isTraversing = false;
private deleteList: MEventData<T>[] = [];
public add(callback: T, thisObj?: any) {
this.list.push({
callback: callback,
thisObj: thisObj,
bindFunc: thisObj ? callback.bind(thisObj) : undefined
});
}
public clear() {
if (this.isTraversing) {
this.deleteList.concat(this.list);
} else {
this.list = [];
}
}
public remove(callback: T, thisObj?: any) {
if (this.isTraversing) {
this.deleteList.push({
callback: callback,
thisObj: thisObj
});
} else {
this.list = this.list.filter(e => e.callback !== callback || e.thisObj !== thisObj);
}
}
public call(...args: any[]) {
this.isTraversing = true;
let item: MEventData<T> = null;
for (let i = 0; i < this.list.length; i++) {
item = this.list[i];
if (item.bindFunc) {
item.bindFunc(...args);
} else {
item.callback(...args);
}
}
for (let i = 0; i < this.deleteList.length; i++) {
this.list = this.list.filter(e => e.callback !== this.deleteList[i].callback || e.thisObj !== this.deleteList[i].thisObj);
}
this.deleteList = [];
this.isTraversing = false;
}
}
\ No newline at end of file
const DefaultDtFactor = 60 / 1000;
import MEvent from "./MEvent";
export default class MTimer {
private static onFrameList: ((dt: number, self: Function) => void)[] = [];
private static timerList: ((self: Function) => void)[] = [];
public static init() {
startTime = Date.now();
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, onUpdate, MTimer);
document.addEventListener("visibilitychange", onVisibilityChange);
}
public static deltaTime: number = 0;
public static destroy() {
_onFrame.clear();
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, onUpdate, MTimer);
document.removeEventListener("visibilitychange", onVisibilityChange);
}
/**
* 帧间隔
*/
public static get deltaTime(): number {
return _deltaTime;
}
/**
* 帧间隔系数:当前帧间隔与标准帧间隔(60帧)的比值
*/
public static get dtFactor() {
return MTimer.deltaTime * DefaultDtFactor;
return MTimer.deltaTime / DefaultDeltaTime;
}
public static init() {
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, () => {
for (let i = 0; i < MTimer.onFrameList.length; i++) {
MTimer.onFrameList[i](MTimer.deltaTime, MTimer.onFrameList[i]);
}
/**
* 注册帧回调函数
*/
/* public static get onFrame(): MEvent<(dt: number) => void> {
return _onFrame;
} */
for (let i = 0; i < MTimer.timerList.length; i++) {
MTimer.timerList[i](MTimer.timerList[i]);
public static onFrame(key: string, callback: (dt: number) => void, thisObj?: any) {
if (key) {
if (onFrameCaches[key]) {
_onFrame.remove(onFrameCaches[key].callback, onFrameCaches[key].thisObj);
delete onFrameCaches[key];
}
}, MTimer);
}
private static removeOnFrame(callback: Function) {
MTimer.onFrameList = MTimer.onFrameList.filter(e => e != callback);
onFrameCaches[key] = {
callback: callback,
thisObj: thisObj
};
}
_onFrame.add(callback, thisObj);
}
public static set(frame: number, onTimeOut: () => void) {
/**
* 设置帧计时器
*/
public static setFrameTimer(frame: number, onTimeOut: () => void) {
let count = 0;
MTimer.timerList.push((self: Function) => {
count += MTimer.dtFactor;
const callback = () => {
if (count >= frame) {
onTimeOut();
MTimer.timerList = MTimer.timerList.filter(e => e != self);
timerTickEvent.remove(callback);
} else {
count += MTimer.dtFactor;
}
});
}
timerTickEvent.add(callback);
}
}
public static onFrame(callback: (deltaTime: number, remove?: () => void) => void, frameCount?: number) {
if (typeof frameCount != "undefined") {
let count = 0;
MTimer.onFrameList.push((deltaTime: number, self: Function) => {
callback(deltaTime);
count += MTimer.dtFactor;
if (count >= frameCount) {
MTimer.removeOnFrame(self);
}
});
} else {
MTimer.onFrameList.push((deltaTime: number, self: Function) => {
callback(deltaTime, () => {
MTimer.removeOnFrame(self);
});
});
}
const onFrameCaches: {
[key: string]: {
callback: (dt: number) => void,
thisObj?: any
}
} = {};
const _onFrame: MEvent<(dt: number) => void> = new MEvent();
const timerTickEvent: MEvent<() => void> = new MEvent();
const DefaultDeltaTime = 1000 / 60;
let _deltaTime: number = 0;
let startTime = 0;
let lastTime = 0;
let curTime = 0;
function updateDeltaTime() {
lastTime = curTime;
curTime = Date.now() - startTime;
_deltaTime = curTime - lastTime;
}
function onVisibilityChange() {
if (document.visibilityState == "visible") {
curTime = Date.now() - startTime;
}
}
function onUpdate() {
updateDeltaTime();
_onFrame.call(MTimer.deltaTime);
}
\ No newline at end of file
import { MUtils } from "./MUtils";
import MTimer from "./MTimer";
class MTween {
class MTweenObject {
public static readonly frameRate = 60;
private tweenList: MTweenBase[] = [];
protected tweenList: MTweenBase[] = [];
public currentTween: MTweenBase = null;
public target: object = null
......@@ -16,7 +16,7 @@ class MTween {
return this;
}
private addTween(tween: MTweenBase) {
protected addTween(tween: MTweenBase) {
if (this.currentTween == null) {
this.currentTween = tween;
} else {
......@@ -29,13 +29,20 @@ class MTween {
return this;
}
public set(props: object) {
for (let key in props) {
this.target[key] = props[key];
}
return this;
}
public call(callback: () => void) {
this.addTween(new CallbackTween(callback, 0, this));
return this;
}
private toFrameRate(duration: number) {
return duration / 1000 * MTween.frameRate;
return duration / 1000 * MTweenObject.frameRate;
}
public update() {
......@@ -52,11 +59,13 @@ class MTween {
}
}
abstract class MTweenBase {
private started = false;
public frameCount: number = 0;
protected tweenObjet: MTween = null;
constructor(frameCount: number, tweenObject: MTween) {
protected tweenObjet: MTweenObject = null;
constructor(frameCount: number, tweenObject: MTweenObject) {
this.tweenObjet = tweenObject;
this.frameCount = frameCount;
}
......@@ -75,7 +84,7 @@ abstract class MTweenBase {
class LinearTween extends MTweenBase {
private once: object = null;
constructor(props: object, frameCount: number, tweenObject: MTween) {
constructor(props: object, frameCount: number, tweenObject: MTweenObject) {
super(frameCount, tweenObject);
this.once = props;
}
......@@ -113,7 +122,7 @@ class LinearTween extends MTweenBase {
class WaitTween extends MTweenBase {
private callback: () => void = null;
constructor(frameCount: number, tweenObject: MTween, callback?: () => void) {
constructor(frameCount: number, tweenObject: MTweenObject, callback?: () => void) {
super(frameCount, tweenObject);
this.callback = callback;
}
......@@ -126,7 +135,7 @@ class WaitTween extends MTweenBase {
class CallbackTween extends MTweenBase {
private callback: () => void = null;
constructor(callback: () => void, frameCount: number, tweenObject: MTween) {
constructor(callback: () => void, frameCount: number, tweenObject: MTweenObject) {
super(frameCount, tweenObject);
this.callback = callback;
}
......@@ -137,54 +146,56 @@ class CallbackTween extends MTweenBase {
}
}
export default class MTweenMgr {
public pause: boolean = false;
private static _instance: MTweenMgr = null;
public static get instance(): MTweenMgr {
if (!this._instance) {
this._instance = new MTweenMgr();
}
return this._instance;
}
export namespace MTween {
export let pause: boolean = false;
private tweenObjectList: MTween[] = [];
let tweenObjectList: MTweenObject[] = [];
// let tweenAnimationList: TweenAnimation[] = [];
private removeQueue: any[] = [];
private isTraversing = false;
let removeQueue: any[] = [];
let isTraversing = false;
public init() {
// engine.startTick(this.update, this);
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.update, this);
export function init() {
// engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, update, this);
MTimer.onFrame("MTween", update, this)
}
public removeTweens(target: object) {
if (this.isTraversing) {
this.removeQueue.push(target);
/* export function destroy() {
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, update, this);
} */
export function removeTweens(target: object) {
if (isTraversing) {
removeQueue.push(target);
} else {
this.tweenObjectList = this.tweenObjectList.filter(e => e.target !== target);
tweenObjectList = tweenObjectList.filter(e => e.target !== target);
}
}
public get(target: object) {
let tween = new MTween(target);
this.tweenObjectList.push(tween);
export function get(target: object) {
let tween = new MTweenObject(target);
tweenObjectList.push(tween);
return tween;
}
private update() {
if (this.pause) return;
/* export function createAnimation(target: object) {
return new TweenAnimation(target);
} */
this.isTraversing = true;
for (let i = 0; i <= this.tweenObjectList.length - 1; i++) {
this.tweenObjectList[i].update();
function update() {
if (pause) return;
isTraversing = true;
for (let i = 0; i <= tweenObjectList.length - 1; i++) {
tweenObjectList[i].update();
}
this.isTraversing = false;
isTraversing = false;
this.tweenObjectList = this.tweenObjectList.filter((tween) => {
tweenObjectList = tweenObjectList.filter((tween) => {
if (tween.currentTween == null) return false;
for (let removeTarget of this.removeQueue) {
for (let removeTarget of removeQueue) {
if (removeTarget === tween.target) {
return false;
}
......@@ -193,8 +204,53 @@ export default class MTweenMgr {
return true;
});
this.removeQueue = [];
removeQueue = [];
/* const filter: TweenAnimation[] = [];
let temp: TweenAnimation = null;
for (let i = 0; i < tweenAnimationList.length; i++) {
temp = tweenAnimationList[i];
temp.update();
if (temp.currentTween != null) {
filter.push(temp);
}
}
return false;
tweenAnimationList = filter; */
}
}
\ No newline at end of file
/* export class TweenAnimation extends MTweenObject {
protected addTween(tween: MTweenBase) {
this.tweenList.push(tween);
}
private pos: number = 0;
public update() {
if (!this.isPlaying) return;
this.currentTween.apply(MTimer.dtFactor);
if (this.currentTween.frameCount <= 0) {
this.pos++;
if (this.pos < this.tweenList.length) {
this.currentTween = this.tweenList[this.pos];
} else {
this.isPlaying = false;
this.currentTween = null;
}
}
}
public play() {
if (this.isPlaying) return;
this.isPlaying = true;
this.pos = 0;
this.currentTween = this.tweenList[0];
tweenAnimationList.push(this);
}
// public onCompleted: () => void;
private isPlaying: boolean = false;
// private inited: boolean = false;
} */
}
import Game from "../Game"
export class DataMgr {
private static _game: Game = null;
public static init(game: Game) {
DataMgr._game = game;
}
public static get game() {
return DataMgr._game;
}
}
\ No newline at end of file
/* import GameMgr from "./GameMgr";
import UILayer from "../UILayer";
import MTimer from "../MTimer";
export default class DebugMgr extends engine.Container {
public enabled: boolean = false;
public enabledGraphic: boolean = false;
export default class DebugMgr extends UILayer {
public enabled: boolean = true;
public enabledGraphic: boolean = true;
private shapeMap = {};
private graphicDebugLayer: engine.Container = null;
private uiLayer: engine.UILayer = null;
private uiLayer: engine.Container = null;
private log: engine.Label = null;
public test: any = null;
private labelFPS = new engine.Label();
public onClick = () => { }
......@@ -15,23 +17,29 @@ export default class DebugMgr extends engine.Container {
super();
if (!this.enabled) return;
//创建图形调试层
this.graphicDebugLayer = new engine.Container();
this.graphicDebugLayer.touchEnabled = false;
this.graphicDebugLayer = new UILayer();
this.addChild(this.graphicDebugLayer);
//创建UI层
this.uiLayer = new engine.UILayer();
this.uiLayer.touchThrough = true;
this.uiLayer = new engine.Container();
this.addChild(this.uiLayer);
//创建日志标签
this.log = new engine.Label("Log");
//创建帧率标签
this.labelFPS.size = 30;
this.labelFPS.fillColor = "rgba(255,255,255,1)";
this.labelFPS.text = "0";
this.labelFPS.x = 20;
this.labelFPS.y = 20;
this.uiLayer.addChild(this.labelFPS);
/* this.log = new engine.Label("Log");
this.log.horizontalCenter = 0;
this.log.top = 50;
this.log.textColor = 0xffffff;
this.log.stroke = 0.5;
this.log.size = 32;
this.uiLayer.addChild(this.log);
this.uiLayer.addChild(this.log); */
//创建调试按钮
let button = new engine.Label("调试");
/* let button = new engine.Label("调试");
button.textColor = 0x000000;
button.borderColor = 0x000000;
button.border = true;
......@@ -40,7 +48,7 @@ export default class DebugMgr extends engine.Container {
this.uiLayer.addChild(button);
button.onTap(this, () => {
this.onClick();
});
}); */
}
public setLog(msg: string) {
......@@ -48,33 +56,36 @@ export default class DebugMgr extends engine.Container {
this.log.text = msg;
}
public drawRect(rect: engine.Rectangle, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
public drawRect(rect: engine.Rectangle, style: GraphicDebug.Style = { color: 0x00ff00, lineSize: 1 }) {
if (!this.enabled || !this.enabledGraphic) return;
let shape = new engine.Shape();
shape.graphics.lineStyle(style.lineSize, style.color);
shape.graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
shape.beginStroke(style.color);
shape.drawRect(rect.x, rect.y, rect.width, rect.height);
shape.endStroke();
this.graphicDebugLayer.addChild(shape);
}
public drawCircle(x: number, y: number, radius: number, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
public drawCircle(x: number, y: number, radius: number, style: GraphicDebug.Style = { color: 0x00ff00, lineSize: 1 }) {
if (!this.enabled || !this.enabledGraphic) return;
let shape = new engine.Shape();
shape.graphics.lineStyle(style.lineSize, style.color);
shape.graphics.drawCircle(x, y, radius);
shape.beginStroke(style.color);
shape.drawCircle(x, y, radius);
shape.endStroke();
this.graphicDebugLayer.addChild(shape);
}
public drawLine(line: GraphicDebug.Line, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
public drawLine(line: GraphicDebug.Line, style: GraphicDebug.Style = { color: 0x00ff00, lineSize: 1 }) {
if (!this.enabled || !this.enabledGraphic) return;
let shape = new engine.Shape();
shape.graphics.lineStyle(style.lineSize, style.color);
shape.graphics.moveTo(line.startX, line.startY);
shape.graphics.lineTo(line.endX, line.endY);
shape.beginStroke(style.color);
shape.moveTo(line.startX, line.startY);
shape.lineTo(line.endX, line.endY);
shape.endStroke();
this.graphicDebugLayer.addChild(shape);
}
public updateLine(key: string, line: GraphicDebug.Line, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
public updateLine(key: string, line: GraphicDebug.Line, style: GraphicDebug.Style = { color: 0x00ff00, lineSize: 1 }) {
if (!this.enabled || !this.enabledGraphic) return;
let shape: engine.Shape = this.shapeMap[key];
if (!shape) {
......@@ -83,13 +94,14 @@ export default class DebugMgr extends engine.Container {
this.shapeMap[key] = shape;
}
shape.graphics.clear();
shape.graphics.lineStyle(style.lineSize, style.color);
shape.graphics.moveTo(line.startX, line.startY);
shape.graphics.lineTo(line.endX, line.endY);
shape.clear();
shape.beginStroke(style.color);
shape.moveTo(line.startX, line.startY);
shape.lineTo(line.endX, line.endY);
shape.endStroke();
}
public updateRect(key: string, rect: engine.Rectangle, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
public updateRect(key: string, rect: engine.Rectangle, style: GraphicDebug.Style = { color: 0x00ff00, lineSize: 1 }) {
if (!this.enabled || !this.enabledGraphic) return;
let shape: engine.Shape = this.shapeMap[key];
if (!shape) {
......@@ -98,12 +110,13 @@ export default class DebugMgr extends engine.Container {
this.shapeMap[key] = shape;
}
shape.graphics.clear();
shape.graphics.lineStyle(style.lineSize, style.color);
shape.graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
shape.clear();
shape.beginStroke(style.color);
shape.drawRect(rect.x, rect.y, rect.width, rect.height);
shape.endStroke();
}
public updateCircle(key: string, x: number, y: number, radius: number, style: GraphicDebug.Style = { color: 0xff0000, lineSize: 1 }) {
public updateCircle(key: string, x: number, y: number, radius: number, style: GraphicDebug.Style = { color: 0x00ff00, lineSize: 1 }) {
if (!this.enabled || !this.enabledGraphic) return;
let shape: engine.Shape = this.shapeMap[key];
if (!shape) {
......@@ -112,16 +125,16 @@ export default class DebugMgr extends engine.Container {
this.shapeMap[key] = shape;
}
shape.graphics.clear();
shape.graphics.lineStyle(style.lineSize, style.color);
shape.graphics.drawCircle(x, y, radius);
shape.clear();
shape.beginStroke(style.color);
shape.drawCircle(x, y, radius);
shape.endStroke();
}
public clearShape(key: string) {
if (!this.enabled || !this.enabledGraphic) return;
let shape: engine.Shape = this.shapeMap[key];
if (!shape) {
console.warn("collider is nonexistent");
return;
}
......@@ -129,15 +142,38 @@ export default class DebugMgr extends engine.Container {
shape.destroy();
}
init(context: engine.Container) {
context.addChild(this);
MTimer.onFrame("DebugMgr", this.onUpdate, this);
}
private lastFrameData: { runTime: number, frameCount: number } = { runTime: 0, frameCount: 0 };
private curFrameData: { runTime: number, frameCount: number } = { runTime: 0, frameCount: 0 };
private resetTimer = 0;
private onUpdate(dt: number) {
this.curFrameData.runTime += dt;
this.curFrameData.frameCount += 1;
this.resetTimer += dt;
let average = (this.curFrameData.runTime + this.lastFrameData.runTime) / (this.curFrameData.frameCount + this.lastFrameData.frameCount)
if (this.resetTimer > 200) {
this.labelFPS.text = Math.round(1000 / average).toString();
this.lastFrameData.runTime = this.curFrameData.runTime;
this.lastFrameData.frameCount = this.curFrameData.frameCount;
this.curFrameData.runTime = 0;
this.curFrameData.frameCount = 0;
this.resetTimer = 0;
}
}
private static _instance: DebugMgr = null;
public static get instance(): DebugMgr {
if (!this._instance) {
if (engine.gameStage) {
this._instance = new DebugMgr();
engine.gameStage.addChild(this._instance);
} else {
console.error("stage is null,DebugMgr can not instantiate");
}
this._instance = new DebugMgr();
}
return this._instance;
......@@ -155,7 +191,4 @@ export namespace GraphicDebug {
endX: number;
endY: number;
}
}
*/
\ No newline at end of file
}
\ No newline at end of file
import Drop from "./Drop";
import { arrayRemove } from "./GUtils";
import Drop from "../Drop";
import MTimer from "../MTimer";
export default class DropBlinkMgr {
private static _instance: DropBlinkMgr = null;
......@@ -26,9 +26,14 @@ export default class DropBlinkMgr {
}
public static init() {
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, DropBlinkMgr.instance.onUpdate, DropBlinkMgr.instance);
MTimer.onFrame("DropBlinkMgr", DropBlinkMgr.instance.onUpdate, DropBlinkMgr.instance);
// engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, DropBlinkMgr.instance.onUpdate, DropBlinkMgr.instance);
}
/* public static destroy() {
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, DropBlinkMgr.instance.onUpdate, DropBlinkMgr.instance);
} */
private frameTimer: number = 0;
public onUpdate() {
......
type ImgType = "star" | "ring" | "fireworks" | "fireworks_line_0" | "fireworks_line_1";
export namespace TextureMgr {
const uuids: {
[key in ImgType]: string[]
} = {
"star": [
"e79f4e51-dbca-45fb-b95a-f52a708e0990",
"1a1b529f-bf68-42cb-8a3e-01b21119b322",
"999d65ba-f7c8-4939-9868-5f974a278752",
"c5743fdf-aadf-4139-b03a-cfd047f85220",
"2aaa2535-d4b9-44c4-8fc2-700c8310e534"
],
"ring": [
"b3c78176-5650-4d49-bc00-cfaf048c5940",
"134e2eec-e393-4ba3-b8cc-f72270bf17c2",
"49092176-3b1c-4ea5-8e02-6050fc5809dd",
"15c46813-ac79-4c5f-8a52-e8cded6dadff",
"64e64fd6-0426-493e-b003-dcafc7e06eb5"
],
"fireworks": [
"84246c84-3f73-4483-abee-54a0c4db7d6f",
"818f5806-9eb4-4e59-ac1f-9bfb6ab06b9b",
"fffc4086-409e-453a-9a98-11a6d4236b72"
],
"fireworks_line_0": [
"c76f6d87-7f84-45ed-a9ac-cf8d4dd47026",
"1fc4fb96-73b7-4250-8886-3c6976eb1139",
"65be7718-f6cd-44d9-89d0-5daf81068316"
],
"fireworks_line_1": [
"10901339-4976-4d38-a3b9-47b7e9025144",
"0692b423-6f14-4ba7-884a-7c177f1583c8",
"2ddd9477-12de-4f13-bb35-5b255f1624bd"
]
}
const caches: {
[uuid: string]: engine.Texture
} = {};
export function get(type: ImgType, index: number) {
const uuid = uuids[type][index];
if (!caches[uuid]) {
caches[uuid] = RES.getRes(uuid);
}
return caches[uuid];
}
}
\ No newline at end of file
......@@ -5,8 +5,8 @@ import Game from "./Game";
export default class MoveObjcet extends GameObject {
public physics: Physics = null;
constructor(context?: Game) {
super(context);
constructor() {
super();
this.physics = this.addComponent(Physics);
}
}
\ No newline at end of file
import Pool, { PoolGroup, PoolElement } from "./Pool";
import { PoolGroup, PoolElement } from "./Pool";
export default class MovieClipMgr {
private static _instance: MovieClipMgr = null;
......@@ -10,9 +10,9 @@ export default class MovieClipMgr {
return this._instance;
}
private movieClipData: { [name: string]: engine.MovieClipData } = {};
// private movieClipData: { [name: string]: engine.MovieClipData } = {};
private pool = new class extends PoolGroup<PoolMovieClip>{
/* private pool = new class extends PoolGroup<PoolMovieClip>{
createPool(key: string) {
return new class extends Pool<PoolMovieClip>{
createElement() {
......@@ -20,10 +20,10 @@ export default class MovieClipMgr {
}
}();
}
}();
}(); */
public load(name: string): boolean {
if (typeof this.movieClipData[name] == "undefined") {
/* if (typeof this.movieClipData[name] == "undefined") {
const data = RES.getRes(name + "_json");
const txtr = RES.getRes(name + "_png");
if (!data || !txtr) {
......@@ -33,26 +33,28 @@ export default class MovieClipMgr {
this.movieClipData[name] = new engine.MovieClipDataFactory(data, txtr).generateMovieClipData(name);
return true;
} else
return true;
return true; */
return false;
}
public create(name: string) {
if (typeof this.movieClipData[name] == "undefined") {
if (!this.load(name)) {
return null;
}
}
return new PoolMovieClip(this.movieClipData[name]);
/* if (typeof this.movieClipData[name] == "undefined") {
if (!this.load(name)) {
return null;
}
}
return new PoolMovieClip(this.movieClipData[name]); */
return null;
}
public get(name: string): PoolMovieClip {
return this.pool.get(name);
/* public get(name: string): PoolMovieClip {
return this.pool.spwan(name);
}
public recycle(name: string, clip: PoolMovieClip) {
this.pool.recycle(name, clip);
clip.destroy();
}
} */
}
class PoolMovieClip extends engine.MovieClip implements PoolElement {
......@@ -60,15 +62,16 @@ class PoolMovieClip extends engine.MovieClip implements PoolElement {
onElementRecycle() { }
playOnComplete(): Promise<void> {
this.gotoAndPlay(0, 1);
//TODO
// this.gotoAndPlay(0, 1);
return new Promise<void>(resolve => {
this.once(engine.Event.COMPLETE, resolve, this);
});
}
autoRecyclePlay(name: string) {
this.playOnComplete().then(() => {
/* this.playOnComplete().then(() => {
MovieClipMgr.instance.recycle(name, this);
});
}); */
}
}
\ No newline at end of file
import Net from "./Net";
import { NetManager } from "../../../libs/tw/manager/NetManager";
import { Buried } from "../../../libs/tw/util/Buried";
import { MUtils } from "./MUtils";
import GameMgr from "../Mgr/GameMgr";
export namespace NetUtils {
export function createSgin(ticketId: number, score: number, gameData: any, submitToken: string): string {
return window['duiba_md5'](ticketId + '' + score + '' + gameData + '' + submitToken);
}
export function getOrderId() {
return Net.cache[NetUtils.getCFG()["doJoin"]]["orderId"];
}
export function gameSubmit(params: {
orderId: any,
score: any,
submitToken: any
}, onSuccess: (res: any) => void, onFail?: (res: any) => any) {
let sgin = createSgin(params.orderId, params.score, "[]", params.submitToken);
Net.sendPost('/hdtool/recon/ngame/ngameSubmit', {
orderId: params.orderId,
score: params.score,
gameData: "[]",
sgin: sgin,
dynamicData: JSON.stringify(`{t2:${new Date().getTime()}}`),
rankId: window["rankId"]
}, onSuccess, onFail);
}
export function ajaxElement(onSuccess: (res: any) => void, onFail?: (res: any) => void) {
let cfg = NetUtils.getCFG();
Net.sendPost(cfg["getElement"], {
hdType: cfg["hdType"],
hdToolId: cfg["hdToolId"],
actId: cfg["actId"],
preview: cfg["preview"]
}, onSuccess, onFail);
}
function doBuried(appIdParam: string, netManager: NetManager, callback: string) {
//初始化埋点数据
Buried.init();
var appId = NetUtils.getCFG()["appId"];
var oaId = NetUtils.getCFG()["appId"];
let data = Buried.createExposure(appId + `.110.${appIdParam}.1`, `202.${oaId}.0.0`);
netManager[callback](data);
console.log("exposure", data);
}
export function doClickBuried(appIdParam: string) {
doBuried(appIdParam, NetManager.ins, "clickLog");
}
export function doShowBuried(appIdParam: string) {
doBuried(appIdParam, NetManager.ins, "showLog");
}
export function encryptSeq(seq: number) {
return Math.round(5 * seq - MUtils.random(0, 4));
}
......@@ -84,19 +29,4 @@ export namespace NetUtils {
let end = splitArr[1].indexOf("/");
return windowUrl.substr(start, end);
}
export function visit() {
return new Promise<any>((resolve, reject) => {
Net.sendGet(Net.Url.visit, undefined, (res) => {
GameMgr.instance.allPeriodEnd = res.data.allPeriodEnd;
GameMgr.instance.leftTimes = res.data.leftTimes;
GameMgr.instance.leftShareTimes = res.data.leftShareTimes;
GameMgr.instance.minEnableCaptchaScore = res.data.minEnableCaptchaScore;
resolve(res);
}, (res) => {
reject(res);
})
});
}
}
\ No newline at end of file
import Pool from "./Pool";
import Bullet from "./Bullet";
import { MConst } from "./MConst";
import PoolMgr from "./PoolMgr";
import GameMgr from "./GameMgr";
import GameObject from "./GameObject";
/* export default class ParticleMgr {
private data: Bullet[] = [];
private layer: engine.Container = null;
constructor(layer: engine.Container) {
this.layer = layer;
}
create(context: MainScene) {
if (this.data.length > 0) {
let e = this.data.pop();
e.onElementInit();
return e;
} else {
let b = new Bullet(context);
this.layer.addChild(b);
return b;
}
}
destroy(bullet: Bullet) {
bullet.onElementRecycle();
this.data.push(bullet);
}
} */
\ No newline at end of file
......@@ -2,24 +2,31 @@ import Physics from "./Physics";
import Collider, { CircleCollider, RectCollider, ColliderType, ColliderGroup, PointCollider } from "./Collider";
import { arrayRemove } from "./GUtils";
import MTimer from "./MTimer";
import DebugMgr from "./Mgr/DebugMgr";
let instanceId1: number = null;
let instanceId2: number = null;
export default class PhycicsSystem {
private static _instance: PhycicsSystem = null;
public static get instance(): PhycicsSystem {
if (!this._instance) {
this._instance = new PhycicsSystem();
if (!PhycicsSystem._instance) {
PhycicsSystem._instance = new PhycicsSystem();
}
return this._instance;
return PhycicsSystem._instance;
}
public static init() {
const ins = PhycicsSystem.instance;
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, ins.onUpdate, ins);
// engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, ins.onUpdate, ins);
MTimer.onFrame("PhycicsSystem", ins.onUpdate, ins);
}
/* public static destroy() {
const ins = PhycicsSystem.instance;
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, ins.onUpdate, ins)
} */
private _enabled: boolean = false;
public set enabled(v: boolean) {
this._enabled = v;
......@@ -98,11 +105,20 @@ export default class PhycicsSystem {
return false;
});
// DebugMgr.instance.clearShape(collider.owner.instanceId.toString());
this.colliderList[collider.group] = arrayRemove(this.colliderList[collider.group], collider);
}
/**检测碰撞 */
public detectCollision() {
/* for (let i of this.colliderList) {
for (let j of i) {
this.drawCollider(j);
}
} */
//查找所有碰撞
let i = 0,
j = 0,
......@@ -153,6 +169,26 @@ export default class PhycicsSystem {
}
}
}
private drawCollider(collider: Collider) {
switch (collider.type) {
case ColliderType.Circle:
let circleCollider = collider as CircleCollider;
let worldCenter = [];
collider.getWorldPosition(worldCenter)
DebugMgr.instance.updateCircle(collider.owner.instanceId.toString(), worldCenter[0], worldCenter[1], circleCollider.radius);
break;
case ColliderType.Rect:
let rectCollider = collider as RectCollider;
let worldPos = [];
rectCollider.getWorldPosition(worldPos);
DebugMgr.instance.updateRect(rectCollider.owner.instanceId.toString(), new engine.Rectangle(worldPos[0], worldPos[1], rectCollider.rect.width, rectCollider.rect.height));
break;
}
}
}
function callDetectFunc(collider1: Collider, collider2: Collider): boolean {
......
import { MConst } from "./MConst";
import { MConfigs } from "./MConfigs";
export default class PlayerController extends engine.Container {
public onTouchMove: (deltaX: number) => void = null;
......@@ -5,23 +8,30 @@ export default class PlayerController extends engine.Container {
private lastX: number = null;
constructor() {
super();
this.width = engine.gameStage.width;
this.height = engine.gameStage.height;
this.width = MConst.DesignResolution.width;
this.height = MConst.DesignResolution.height;
this.addEventListener(engine.MouseEvent.MOUSE_DOWN, (e: engine.MouseEvent) => {
this.touchId = e.instanceId;
this.lastX = e.stageX;
this.lastX = e.clientX;
}, this);
this.addEventListener(engine.MouseEvent.MOUSE_MOVE, (e: engine.MouseEvent) => {
if (e.instanceId != this.touchId || this.touchId == null || this.lastX == null) return;
this.onTouchMove && this.onTouchMove(e.stageX - this.lastX)
this.lastX = e.stageX;
this.onTouchMove && this.onTouchMove(e.clientX - this.lastX)
this.lastX = e.clientX;
}, this);
this.removeEventListener(engine.MouseEvent.MOUSE_UP, (e: engine.MouseEvent) => {
this.addEventListener(engine.MouseEvent.MOUSE_UP, (e: engine.MouseEvent) => {
if (e.instanceId != this.touchId) return;
this.touchId = null;
this.lastX = null;
}, this);
let rect = new engine.Rect();
rect.width = 750;
rect.height = 1624;
rect.fillColor = "rgba(255,255,255,1)"
rect.alpha = 0;
this.addChild(rect);
}
}
\ No newline at end of file
import { MUtils } from "./MUtils";
import MTweenMgr from "./MTween";
import { MTween } from "./MTween";
export default abstract class Pool<T extends PoolElement>{
private data: T[] = [];
public get(...args: any[]): T {
if (this.data.length > 0) {
let e = this.data.pop();
e.onElementInit();
return e;
} else {
return this.createElement(...args);
}
}
public recycle(element: T) {
MTweenMgr.instance.removeTweens(element);
element.onElementRecycle();
for (let i of this.data) {
if (i === element) return;
}
this.data.push(element);
export abstract class PoolGroup<T extends PoolElement>{
protected data: { [key: string]: Pool<T> } = {}
public recycle(key: string, element: T) {
this.data[key].recycle(element);
}
protected abstract createElement(...args: any[]): T;
public abstract spwan(...args: any[]): T;
}
export abstract class PoolGroup<T extends PoolElement>{
private data: {
[key: string]: Pool<T>
} = {};
export abstract class Pool<T extends PoolElement>{
protected data: T[] = [];
public get(key: string): T {
return this.getValue(key).get();
}
public recycle(key: string, element: T) {
this.getValue(key).recycle(element);
}
private getValue(key: string) {
this.data[key] = this.data[key] || this.createPool(key);
return this.data[key];
public recycle(element: T) {
element.onElementRecycle();
this.data.push(element);
}
protected abstract createPool(key: string): Pool<T>;
public abstract spwan(...args: any[]): T;
}
export interface PoolElement {
/**回收元素时的调用 */
onElementRecycle(): void;
onElementInit(): void;
poolKey?: string;
}
\ No newline at end of file
import Pool, { PoolElement } from "./Pool";
/* import { PoolElement } from "./Pool";
import GameObject from "./GameObject";
export default abstract class PoolMgr<T extends PoolElement & engine.Container>{
protected layer: engine.Container = null;
private pool: Pool<T> = new class extends Pool<T>{
public layer: engine.Container = null;
public pool: Pool<T> = new class extends Pool<T>{
private context: PoolMgr<T> = null;
constructor(context: PoolMgr<T>) {
super();
......@@ -29,4 +29,4 @@ export default abstract class PoolMgr<T extends PoolElement & engine.Container>{
}
abstract createElement(...args: any[]): T;
}
\ No newline at end of file
} */
\ No newline at end of file
import { Pool, PoolGroup } from "../Pool";
import Ball from "../Ball";
import Game from "../Game";
import { DataMgr } from "../Mgr/DataMgr";
class BallPool extends Pool<Ball>{
public spwan(sizeIndex: number) {
let element: Ball = null;
if (this.data.length > 0) {
element = this.data.shift();
element.onElementInit();
} else {
element = new Ball(sizeIndex);
}
DataMgr.game._ballList.push(element);
return element;
}
public recycle(element: Ball) {
super.recycle(element);
DataMgr.game._ballList = DataMgr.game._ballList.filter(e => e !== element);
}
};
class BallPoolGroup extends PoolGroup<Ball>{
public spwan(sizeIndex: number) {
const key = sizeIndex.toString();
if (!this.data[key]) {
this.data[key] = new BallPool()
}
let element = this.data[key].spwan(sizeIndex);
element.poolKey = key;
return element;
}
}
let ballPool: BallPoolGroup = new BallPoolGroup();
export default ballPool;
\ No newline at end of file
import { Pool, PoolElement, PoolGroup } from "../Pool";
import { BoomEffectSprite } from "../BoomEffect";
/* import BoomEffect from "../BoomEffect";
import { Pool, PoolGroup } from "../Pool";
class BoomEffectPool extends Pool<BoomEffect> {
public spwan(color: number, size: number): BoomEffect {
if (this.data.length > 0) {
const element = this.data.shift();
element.onElementInit();
return element;
} else {
return new BoomEffect(color, size);
}
}
}
class BoomEffectPoolGroup extends PoolGroup<BoomEffect> {
public spwan(color: number, size: number) {
const key = color.toString() + size.toString();
if (!this.data[key]) {
this.data[key] = new BoomEffectPool()
}
const element = this.data[key].spwan(color, size);
element.poolKey = key;
return element;
}
}
let boomEffectPool = new BoomEffectPoolGroup();
export default boomEffectPool;
*/
import Bullet from "../Bullet";
import { Pool } from "../Pool";
class BulletPool extends Pool<Bullet> {
public spwan() {
if (this.data.length > 0) {
const element = this.data.shift();
element.onElementInit();
return element;
} else {
return new Bullet();
}
}
}
let bulletPool: BulletPool = new BulletPool();
export default bulletPool;
\ No newline at end of file
import { Pool, PoolGroup } from "../Pool";
import Drop from "../Drop";
class DropPool extends Pool<Drop> {
public spwan(id: number) {
if (this.data.length > 0) {
const element = this.data.shift();
element.onElementInit();
return element;
} else {
return new Drop(id);
}
}
}
class DropPoolGroup extends PoolGroup<Drop>{
public spwan(id: string) {
if (!this.data[id]) {
this.data[id] = new DropPool()
}
return this.data[id].spwan(id);
}
}
let dropPool: DropPoolGroup = new DropPoolGroup();
export default dropPool;
\ No newline at end of file
import Game from "./Game";
import PhycicsSystem from "./PhycicsSystem";
import MTimer from "./MTimer";
import { MTween } from "./MTween";
import DropBlinkMgr from "./Mgr/DropBlinkMgr";
import Ball from "./Ball";
import MEvent from "./MEvent";
import { DataMgr } from "./Mgr/DataMgr";
import DebugMgr from "./Mgr/DebugMgr";
import FrameAnimation from "./Component/FrameAnimation";
import Drop from "./Drop";
import { SpBoomEffectMgr } from "./SpBoomEffect";
/**
* Created by rockyl on 2019-11-22.
*/
export class ShootPlanet extends engine.Container {
public game: Game = null;
private onFrame: MEvent<(t: number) => void> = new MEvent();
constructor() {
super();
this.customProperty();
this.game = new Game(this);
this.width = 750;
this.height = 1624;
this.addEventListener(engine.Event.REMOVED_FROM_STAGE, this.onDestroy, this);
this.init();
let rect = new engine.Rect();
rect.width = 100;
rect.height = 100;
this.addChild(rect);
}
private init() {
RES.getRes = function (uuid: string) {
return engine.Texture.from(uuid);
}
PhycicsSystem.init();
MTimer.init();
MTween.init();
DropBlinkMgr.init();
DataMgr.init(this.game);
DebugMgr.instance.init(this);
MTimer.onFrame("FrameAnimation", FrameAnimation.onUpdate, FrameAnimation);
MTimer.onFrame("SpBoomEffectMgr", SpBoomEffectMgr.onUpdate, SpBoomEffectMgr);
}
private onDestroy() {
MTimer.destroy();
}
private customProperty() {
window["RES"] = {
getRes: function (uuid: string) {
return engine.Texture.from(uuid);
}
};
Math.clamp = function (target: number, min: number, max: number) {
if (target > max) target = max;
if (target < min) target = min;
return target;
}
Object.defineProperty(engine.Point, 'length', {
Object.defineProperty(engine.Point.prototype, 'length', {
get: function () {
return Math.sqrt(this.x * this.x + this.y * this.y);
}
});
engine.DisplayObject.prototype.destroy = function () {
this.parent.removeChild(this);
}
}
}
......
......@@ -34,34 +34,31 @@ export default class SoundMgr {
this._musicEnabled = v;
}
private music: engine. = null;
private musicChannel: engine.SoundChannel = null;
private loopChannelMap: { [name: string]: engine.SoundChannel } = {}
// private music: engine. = null;
// private musicChannel: engine.SoundChannel = null;
// private loopChannelMap: { [name: string]: engine.SoundChannel } = {}
private effectPool: { [name: string]: PoolSound[] } = {}
public firstSeted = false;
public setMusic(url: string) {
this.music = RES.getRes(url);
/* if (this.musicChannel) {
this.playMusic();
} */
// this.music = RES.getRes(url);
}
public playMusic() {
if (this.music == null) {
/* if (this.music == null) {
console.warn("music do not set");
return;
}
this.musicChannel && this.musicChannel.stop();
this.musicChannel = this.music.play(0, 0);
this.musicChannel = this.music.play(0, 0); */
}
public stopMusic() {
this.musicChannel && (this.musicChannel.stop());
// this.musicChannel && (this.musicChannel.stop());
}
public playEffect(name: string, loop: boolean = false) {
if (!this.effectEnabled) return;
/* if (!this.effectEnabled) return;
let poolSound = this.createSound(name, loop);
let channel = poolSound.sound.play(0, loop ? 0 : 1);
......@@ -77,19 +74,19 @@ export default class SoundMgr {
resolve();
}, this);
});
}
} */
}
public stopLoopEffect(name: string) {
if (this.loopChannelMap[name]) {
/* if (this.loopChannelMap[name]) {
this.loopChannelMap[name].stop();
}
} */
}
private t: number = 0;
private createSound(name: string, loop: boolean): PoolSound {
let soundList = this.effectPool[name];
/* let soundList = this.effectPool[name];
if (!soundList || soundList.length <= 0) {
let poolSound = new PoolSound(name, RES.getRes(name), loop);
if (poolSound.name == "shoot_mp3") {
......@@ -98,18 +95,19 @@ export default class SoundMgr {
return poolSound;
} else {
return soundList.pop();
}
} */
return null;
}
private recycleSound(poolSound: PoolSound) {
delete this.loopChannelMap[poolSound.name];
/* delete this.loopChannelMap[poolSound.name];
this.effectPool[poolSound.name] = this.effectPool[poolSound.name] || [];
this.effectPool[poolSound.name].push(poolSound);
this.effectPool[poolSound.name].push(poolSound); */
}
}
class PoolSound {
private loop = false;
/* private loop = false;
public onRecycle = (sound: PoolSound) => { }
public sound: engine.Sound = null;
public name: string = null;
......@@ -117,5 +115,5 @@ class PoolSound {
this.name = name;
this.sound = sound;
this.loop = loop;
}
} */
}
\ No newline at end of file
import { TextureMgr } from "./Mgr/TextureMgr";
import { MUtils } from "./MUtils";
import MTimer from "./MTimer";
import { Pool, PoolGroup, PoolElement } from "./Pool";
const InitSpeedValue: number = 0.08;
const alphaDuration: number = 300;
const alphaPerFrame: number = 1 / (alphaDuration / (1000 / 60));
const InitAcceleration: number = -0.00005;
const noAlphaDuration: number = 200 / (1000 / 60);
class Line {
public sprite: engine.Sprite = null;
private direction: engine.Point = null;
private speedValue: number = InitSpeedValue;
constructor(parent: engine.Container, type: number, color: number, rotation: number) {
const sprite = new engine.Sprite(TextureMgr.get(("fireworks_line_" + type) as any, color));
parent.addChild(sprite);
sprite.anchorX = sprite.width / 2;
// sprite.y = -sprite.height;
/* let mask = new engine.Graphics();
mask.beginFill(0xffffff);
mask.drawRect(0, 0, sprite.width, 200);
mask.endFill();
parent.addChild(mask);
sprite.mask = mask; */
sprite.rotation = rotation;
// mask.rotation = rotation;
// mask.anchorX = sprite.anchorX;
this.sprite = sprite;
//计算方向
let dir = MUtils.getVector(rotation + 90)
this.direction = dir;
}
private frameTimer = 0;
public init() {
this.sprite.y = -this.sprite.height;
this.sprite.alpha = 1;
this.sprite.x = 0;
this.sprite.y = 0;
this.frameTimer = 0;
this.speedValue = InitSpeedValue;
}
public onUpdate(dt: number) {
this.sprite.x += this.direction.x * this.speedValue * dt;
this.sprite.y += this.direction.y * this.speedValue * dt;
if (this.frameTimer > noAlphaDuration) {
this.sprite.alpha -= alphaPerFrame * MTimer.dtFactor;
}
this.frameTimer++;
/* if (this.speedValue < InitSpeedValue * 0.4) {
} */
/* this.speedValue += InitAcceleration * dt;
if (this.speedValue < 0) {
this.speedValue = 0;
} */
}
}
export namespace SpBoomEffectMgr {
export let list: SpBoomEffect[] = [];
export function onUpdate(dt: number) {
let filter: SpBoomEffect[] = [];
for (let i of list) {
if (i.onUpdate(dt)) {
filter.push(i);
}
}
list = filter;
}
}
class SpBoomEffect extends engine.Container implements PoolElement {
private lines: Line[] = [];
public onUpdate(dt: number) {
for (let i of this.lines) {
i.onUpdate(dt);
}
if (this.lines[0].sprite.alpha <= 0) {
spBoomEffectPool.recycle(this.poolKey, this);
return false;
}
return true;
}
constructor(color: number, size: number) {
super();
this.scaleX = this.scaleY = 0.5 * size + 0.5;
this.rotation = MUtils.random(0, 90);
for (let i = 0; i < 16; i++) {
let line = new Line(this, i % 2, color, i * 22.5);
this.lines.push(line);
}
SpBoomEffectMgr.list.push(this);
}
onElementInit() {
this.visible = true;
this.alpha = 1;
for (let i of this.lines) {
i.init();
}
SpBoomEffectMgr.list.push(this);
}
onElementRecycle() {
this.visible = false;
}
poolKey: string;
}
class SpBoomEffectPool extends Pool<SpBoomEffect> {
public spwan(color: number, size: number): SpBoomEffect {
if (this.data.length > 0) {
const element = this.data.shift();
element.onElementInit();
return element;
} else {
return new SpBoomEffect(color, size);
}
}
}
class SpBoomEffectPoolGroup extends PoolGroup<SpBoomEffect> {
public spwan(color: number, size: number) {
const key = color.toString() + size;
if (!this.data[key]) {
this.data[key] = new SpBoomEffectPool()
}
const element = this.data[key].spwan(color, size);
element.poolKey = key;
return element;
}
}
let spBoomEffectPool: SpBoomEffectPoolGroup = new SpBoomEffectPoolGroup();
export default spBoomEffectPool;
import { MConst } from "./MConst";
export default class UILayer extends engine.Container {
constructor() {
super();
this.width = MConst.DesignResolution.width;
this.height = MConst.DesignResolution.height;
}
}
\ No newline at end of file
{
"name": "Test1",
"props": {
},
"name": "ShootPlanet",
"props": {},
"assets": [
{
"url": "//yun.duiba.com.cn/aurora/af90069732223c75818c4799b3130bd0f0ad4ff8.png",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/05c41456de4c00c1483fc4f7f0b9b4523611639a.png",
"uuid": "a25bc02b-ceae-41a0-9a0f-0b93239991b0",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/44e26ee861316295f6f41a66f3babd89ab26befe.png",
"uuid": "d99368b8-af5d-4d9e-981e-7bce3e1c1e84",
"ext": ".jpg"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/448c4a329ee1f0417c119d813157abc98373a641.png",
"uuid": "83144d98-b464-48d2-95ac-5b189f134ba7",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/ff9e4e7d73cd934fed1d0ebd6d75f9d3c1007bf0.png",
"uuid": "30fd41be-d702-4511-93d8-5f4609ea4c7d",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/ef6f4b0a082fbba2b46676c170d1ea3e1192813a.png",
"uuid": "6211fb97-ba4a-4b79-b178-09dcf63c16d4",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/d54ca738eb758cce049d17484e9f2828dca488f4.png",
"uuid": "d8daa113-0d75-4139-9e81-c54b7522c890",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/e0e575987ca98675a02ce8a45e4cc10837accf52.png",
"uuid": "fbd26824-9f87-4784-b825-1d824de97023",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/947dc2602f827a38aac5e3db747e0c056cd25fda.png",
"uuid": "39843f75-8caa-4cee-bff5-91fb759b691b",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/265b357ab662f116ddfb28561aa68e73cfd455f5.png",
"uuid": "bd94b3e6-3c99-490f-95ef-ca0c056d7727",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/7f651660509a1a65edb537e6ddbb322aad865a5d.png",
"uuid": "d8eab9fc-104e-4b39-88d6-455ed8632703",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/23925c752d7091d16587fda9e66f697f9f088a6f.png",
"uuid": "48f98d84-d30e-4dfe-aa92-c45bde5cefd8",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/eb19ad1517122edb595f71ce99348d1c6963a03a.png",
"uuid": "8d42fd9e-907b-4587-9a6f-a634909b8b8a",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/b95848ec6c510347c040f0c11f0d5685fcc110aa.png",
"uuid": "09bdff41-2fe3-4298-ad3a-1d2eaf6af778",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/b496f6d0a7c0592910f8e401fec85132846791d4.png",
"uuid": "64e64fd6-0426-493e-b003-dcafc7e06eb5",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/69b2f45bc53b8cf619516dc003142ea53a231650.png",
"uuid": "15c46813-ac79-4c5f-8a52-e8cded6dadff",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/ba722374a8d157b8c8d383c7fcab67ae13f3a7cc.png",
"uuid": "49092176-3b1c-4ea5-8e02-6050fc5809dd",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/8a9ed6505d18483361890f0f5a843824fb4a3457.png",
"uuid": "134e2eec-e393-4ba3-b8cc-f72270bf17c2",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/d6391cb9b2d00689bb510137796e8731ea98634e.png",
"uuid": "b3c78176-5650-4d49-bc00-cfaf048c5940",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/579d259f801eaa795ead6fe4d51ea3c767e6f392.png",
"uuid": "2aaa2535-d4b9-44c4-8fc2-700c8310e534",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/42bc95fc3d175e621e48fb18294e0b2aa0448089.png",
"uuid": "c5743fdf-aadf-4139-b03a-cfd047f85220",
"ext": ".png"
},
{
"url": " //yun.duiba.com.cn/aurora/assets/afff371d4452f4e857b282a25828ed3f500fa849.png",
"uuid": "999d65ba-f7c8-4939-9868-5f974a278752",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/2bbe18fa5bb36cc585eae9a09266045e2e7c7d2e.png",
"uuid": "1a1b529f-bf68-42cb-8a3e-01b21119b322",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/3f62afe9aeace2a22926f95e6852ab995d4d3ff8.png",
"uuid": "e79f4e51-dbca-45fb-b95a-f52a708e0990",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/bea5eaeb4d8234dbc9d411e88d81361abd94bc3f.png",
"uuid": "f7221f86-f376-40ce-b0e8-f7ea573ec780",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/7c168eccc053c3f13e6d75e7fe072603a363d1ad.png",
"uuid": "c9dbd728-1844-4910-b1ef-e84ce10dc422",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/18585d2fb775f402c0e1c03b0b9963eacd9ab4a3.png",
"uuid": "41182131-7050-4b95-9dce-45275b70738d",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/89bfff5b59c0b58566ff45342aba96f597e023a8.png",
"uuid": "17d8e000-b290-4972-bcab-cb819a6cf51b",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/6033bbe3a30a4fc1b0040b451a073745c8a4251b.png",
"uuid": "3f7faebf-64da-44a4-8152-0c35fcc29fe5",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/65378e37b388fddb8fe5124a8e9bc49ed1a716fb.png",
"uuid": "217164f4-a185-429c-8706-818137a4e438",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/5f33588232aca7ce0a1850422d37740ce0a2ffcc.png",
"uuid": "b4d821e8-8274-4b60-95d0-47da803ac5cf",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/5fd194c102e8612cd39ce6001347b38b2d0c8a92.png",
"uuid": "53c65221-3fbc-41d9-8cef-8a846876fe06",
"ext": ".png"
},
{
"url": "",
"uuid": "",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/4b4af30efa87c1ec74e361a505053639f1d8e471.png",
"uuid": "ddf5128e-be66-4c00-8505-e4167aac37bc",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/6b0842ba39345e2a77105fc8118c1d867e040925.png",
"uuid": "84246c84-3f73-4483-abee-54a0c4db7d6f",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/9bd552a1c56753c2f2f21fc9b6036ee85448bc4b.png",
"uuid": "818f5806-9eb4-4e59-ac1f-9bfb6ab06b9b",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/096db2033ffd30cfeb054342c2a8af8c9b0f46b7.png",
"uuid": "fffc4086-409e-453a-9a98-11a6d4236b72",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/704c371640166a3400d99e9eb8b56f64a3da7683.png",
"uuid": "10901339-4976-4d38-a3b9-47b7e9025144",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/a50ab9c665f406c9b871fbc253c571b19800c949.png",
"uuid": "c76f6d87-7f84-45ed-a9ac-cf8d4dd47026",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/9ffe79cc377c2e76744f1794c1d6f3c3539bb25e.png",
"uuid": "1fc4fb96-73b7-4250-8886-3c6976eb1139",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/9c8d28ad86b02f9250f395ddfabfbc587e0bc4cf.png",
"uuid": "0692b423-6f14-4ba7-884a-7c177f1583c8",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/79e8a046f640c98fd449cec18bbefb12e7684235.png",
"uuid": "65be7718-f6cd-44d9-89d0-5daf81068316",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/dd5a9c4b4cb94bd0049890c0aad320ec539a7e16.png",
"uuid": "2ddd9477-12de-4f13-bb35-5b255f1624bd",
"ext": ".png"
}
]
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta content="telephone=no" name="format-detection" />
<title>我的奖品</title>
<script>
!function (e, i) { var t = e.documentElement, n = navigator.userAgent.match(/iphone|ipod|ipad/gi), a = n ? Math.min(i.devicePixelRatio, 3) : 1, m = "orientationchange" in window ? "orientationchange" : "resize"; t.dataset.dpr = a; for (var d, l, c = !1, o = e.getElementsByTagName("meta"), r = 0; r < o.length; r++)l = o[r], "viewport" == l.name && (c = !0, d = l); if (c) d.content = "width=device-width,initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0,user-scalable=no"; else { var o = e.createElement("meta"); o.name = "viewport", o.content = "width=device-width,initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0,user-scalable=no", t.firstElementChild.appendChild(o) } var s = function () { var e = t.clientWidth; e / a > 640 && (e = 640 * a), window.remScale = e / 640, t.style.fontSize = 200 * (e / 640) + "px" }; s(), e.addEventListener && i.addEventListener(m, s, !1) }(document, window);
</script>
<script type="text/javascript">
if (localStorage && localStorage.iswebp) {
document.getElementsByTagName('html')[0].setAttribute('duiba-webp', 'true')
}
</script>
</head>
<body>
<link rel="stylesheet" type="text/css" href="https://yun.duiba.com.cn/h5/common/base_201710241714.css">
<link href="//yun.duiba.com.cn/h5/activity_custom/skins/nanjing-record-190807/index.6748f280.css" rel="stylesheet">
<div id="db-content" style="display: none;">
<!--<a href="javascript:history.go(-1)" class="back1" ></a>-->
<div class="recordBox">
<!-- 填充 -->
</div>
<div class="nomore">已经没有更多了!</div>
<div style="display: none" class="noData">暂无数据</div>
</div>
<script>
var CFG = CFG || {};
CFG.needCouponModal = false;
CFG.projectId = 'projectx/' + location.pathname.split('/')[2];
CFG.asyncFiles = [
'//yun.duiba.com.cn/h5/activity_custom/skins/nanjing-record-190807/components.5560b2c5.js',
'//yun.duiba.com.cn/h5/activity_custom/skins/nanjing-record-190807/components.0e433876.css'
]
</script>
<script type="text/javascript" crossorigin="anonymous"
src="https://yun.duiba.com.cn/h5/common/base_201812191516.js"></script>
<script type="text/javascript" crossOrigin="anonymous"
src="//yun.duiba.com.cn/h5/activity_custom/skins/nanjing-record-190807/index.5815e161.js"></script>
<script type="text/javascript" src="https://m1.cmbc.com.cn/CMBC_MBServer/scripts/js/cmbcForClient.js"></script>
<script>
var titleName = document.title
var title = {
"title": titleName, // 标题名
"leftButton": { // 左按钮
"exist": "true", // true:显示左按钮,false:也显示左按钮,客户端不调用左按钮的返回事件
"name": "返回", // 按钮的说明
"func": "window.history.go(-1)" // 点击左按钮时,客户端回调服务器的方法
},
"rightButton": {
"exist": "false" // 不显示右按钮
}
}
setTitleBar(title);
</script>
<script>
/* var oHead = document.querySelector('body');
var oScript = document.createElement('script');
oScript.type = 'text/javascript';
oScript.src = '//yun.duiba.com.cn/webapp/js/vconsole.min.js';
oHead.appendChild(oScript);
oScript.onload = function () {
var vConsole = new VConsole();
} */
</script>
</body>
</html>
\ No newline at end of file
{
"file": "num2.png",
"frames": {
".": {
"x": 3,
"y": 215,
"w": 16,
"h": 17,
"offX": 7,
"offY": 49,
"sourceW": 29,
"sourceH": 66
},
"k": {
"x": 155,
"y": 3,
"w": 42,
"h": 65,
"offX": 6,
"offY": 0,
"sourceW": 48,
"sourceH": 66
},
"0": {
"x": 3,
"y": 144,
"w": 44,
"h": 65,
"offX": 2,
"offY": 1,
"sourceW": 48,
"sourceH": 66
},
"1": {
"x": 145,
"y": 74,
"w": 27,
"h": 65,
"offX": 7,
"offY": 0,
"sourceW": 48,
"sourceH": 66
},
"2": {
"x": 53,
"y": 74,
"w": 41,
"h": 64,
"offX": 3,
"offY": 1,
"sourceW": 48,
"sourceH": 66
},
"3": {
"x": 100,
"y": 74,
"w": 39,
"h": 65,
"offX": 5,
"offY": 1,
"sourceW": 48,
"sourceH": 66
},
"4": {
"x": 3,
"y": 3,
"w": 48,
"h": 64,
"offX": 0,
"offY": 1,
"sourceW": 48,
"sourceH": 66
},
"5": {
"x": 53,
"y": 144,
"w": 39,
"h": 65,
"offX": 5,
"offY": 1,
"sourceW": 48,
"sourceH": 66
},
"6": {
"x": 106,
"y": 3,
"w": 43,
"h": 65,
"offX": 3,
"offY": 1,
"sourceW": 48,
"sourceH": 66
},
"7": {
"x": 203,
"y": 3,
"w": 42,
"h": 64,
"offX": 3,
"offY": 1,
"sourceW": 48,
"sourceH": 66
},
"8": {
"x": 3,
"y": 73,
"w": 44,
"h": 65,
"offX": 2,
"offY": 1,
"sourceW": 48,
"sourceH": 66
},
"9": {
"x": 57,
"y": 3,
"w": 43,
"h": 65,
"offX": 2,
"offY": 1,
"sourceW": 48,
"sourceH": 66
}
}
}
\ No newline at end of file
let t = {
}
\ No newline at end of file
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