Commit 86efa534 authored by wildfirecode13's avatar wildfirecode13

1

parent 5c486690
This diff is collapsed.
...@@ -5,15 +5,9 @@ ...@@ -5,15 +5,9 @@
const assets = [ const assets = [
{ {
"name": "方块素材0", "name": "方块素材0",
"url": "//yun.duiba.com.cn/aurora/assets/4c6fba8e09e6fa6015e911870c295ff3e11bde72.svga", "url": "//yun.duiba.com.cn/aurora/assets/f4a8043e67c73dcb65d5c1f2e09aa302ef977373.svga",
"uuid": "c3e908ad-a895-4463-98a9-c78c19ba5e6b", "uuid": "c3e908ad-a895-4463-98a9-c78c19ba5e6b",
"ext": ".svga" "ext": ".svga"
},
{
"name": "方块素材0_hit",
"url": "//yun.duiba.com.cn/aurora/assets/4c6fba8e09e6fa6015e911870c295ff3e11bde72.svga",
"uuid": "79cd10e7-67c4-4cb1-9e56-598100162a7c",
"ext": ".svga"
} }
]; ];
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -47,25 +47,15 @@ ...@@ -47,25 +47,15 @@
"type": "array<string>", "type": "array<string>",
"default": "方块素材0" "default": "方块素材0"
}, },
"blockHitAssets": {
"alias": "方块素材组撞击状态",
"type": "array<string>",
"default": "方块素材0_hit"
},
"blockHitOffsetY": { "blockHitOffsetY": {
"alias": "方块素材组撞击状态Y轴锚点", "alias": "方块素材组撞击状态Y轴锚点",
"type": "number", "type": "number",
"default": 75 "default": 75
}, },
"blockProfectOffset": {
"alias": "方块素材组完美状态锚点",
"type": "vector2",
"default": "-100,35"
},
"blockBaseOffset": { "blockBaseOffset": {
"alias": "初始方块偏移", "alias": "初始方块偏移",
"type": "number", "type": "number",
"default": -40 "default": -20
}, },
"blockShadowOffset": { "blockShadowOffset": {
"alias": "初始方块阴影偏移", "alias": "初始方块阴影偏移",
...@@ -110,7 +100,7 @@ ...@@ -110,7 +100,7 @@
"blockHitHeight": { "blockHitHeight": {
"alias": "方块碰撞高度", "alias": "方块碰撞高度",
"type": "number", "type": "number",
"default": 160 "default": 120
}, },
"blockPaddingTop": { "blockPaddingTop": {
"alias": "方块上边距", "alias": "方块上边距",
...@@ -205,42 +195,42 @@ ...@@ -205,42 +195,42 @@
"playerReadyAnchor": { "playerReadyAnchor": {
"alias": "角色准备锚点", "alias": "角色准备锚点",
"type": "vector2", "type": "vector2",
"default": "150,210" "default": "75,122"
}, },
"playerReady2Anchor": { "playerReady2Anchor": {
"alias": "角色准备2锚点", "alias": "角色准备2锚点",
"type": "vector2", "type": "vector2",
"default": "150,210" "default": "75,122"
}, },
"playerJumpAnchor": { "playerJumpAnchor": {
"alias": "角色跳起锚点", "alias": "角色跳起锚点",
"type": "vector2", "type": "vector2",
"default": "150,210" "default": "75,122"
}, },
"playerFallAnchor": { "playerFallAnchor": {
"alias": "角色下落锚点", "alias": "角色下落锚点",
"type": "vector2", "type": "vector2",
"default": "150,210" "default": "75,122"
}, },
"playerHitAnchor": { "playerHitAnchor": {
"alias": "角色撞开锚点", "alias": "角色撞开锚点",
"type": "vector2", "type": "vector2",
"default": "150,210" "default": "75,122"
}, },
"playerParachuteAnchor": { "playerParachuteAnchor": {
"alias": "角色降落锚点", "alias": "角色降落锚点",
"type": "vector2", "type": "vector2",
"default": "150,210" "default": "126,212"
}, },
"playerLandNormalAnchor": { "playerLandNormalAnchor": {
"alias": "角色正常落地锚点", "alias": "角色正常落地锚点",
"type": "vector2", "type": "vector2",
"default": "150,210" "default": "75,122"
}, },
"playerLandPerfectAnchor": { "playerLandPerfectAnchor": {
"alias": "角色完美落地锚点", "alias": "角色完美落地锚点",
"type": "vector2", "type": "vector2",
"default": "150,210" "default": "75,122"
}, },
"playerLandEffectAnchor": { "playerLandEffectAnchor": {
"alias": "角色落地特效锚点", "alias": "角色落地特效锚点",
...@@ -250,7 +240,7 @@ ...@@ -250,7 +240,7 @@
"playerLandSideAnchor": { "playerLandSideAnchor": {
"alias": "角色边缘落地锚点", "alias": "角色边缘落地锚点",
"type": "vector2", "type": "vector2",
"default": "150,210" "default": "75,122"
}, },
"playerLandPrefectAnchor": { "playerLandPrefectAnchor": {
"alias": "角色完美落地锚点", "alias": "角色完美落地锚点",
...@@ -275,12 +265,6 @@ ...@@ -275,12 +265,6 @@
}, },
"assets": [ "assets": [
{
"name": "完美方块素材",
"url": "//yun.duiba.com.cn/aurora/assets/e2150383e8391a2972bc43fd888e4c1250e1933a.svga",
"uuid": "7499df87-4155-406b-8c2b-fea972719f39",
"ext": ".svga"
},
{ {
"name": "背景图", "name": "背景图",
"url": "//yun.duiba.com.cn/aurora/assets/c90e6bc6718e4cc83d30bf2ce8b9f80a909adbee.jpg", "url": "//yun.duiba.com.cn/aurora/assets/c90e6bc6718e4cc83d30bf2ce8b9f80a909adbee.jpg",
...@@ -363,9 +347,15 @@ ...@@ -363,9 +347,15 @@
{ {
"name": "降落", "name": "降落",
"url": "//yun.duiba.com.cn/aurora/assets/0c33a8285661684f24062af815a38befdbf36a06.svga", "url": "//yun.duiba.com.cn/aurora/assets/0c33a8285661684f24062af815a38befdbf36a06.svga",
"uuid": "82b514a9-69c4-425c-a77d-f34efeef1997", "uuid": "f234sf",
"ext": ".svga" "ext": ".svga"
}, },
{
"name": "降落pic",
"url": "////yun.duiba.com.cn/aurora/assets/e42a48c9b4a47dc180523bdeecd6b7305e088e27.png",
"uuid": "9sf881289",
"ext": ".png"
},
{ {
"name": "钱袋-静态", "name": "钱袋-静态",
"url": "//yun.duiba.com.cn/aurora/assets/c5d04d5caf2dc812baeebdd34ea1abb17d183f44.png", "url": "//yun.duiba.com.cn/aurora/assets/c5d04d5caf2dc812baeebdd34ea1abb17d183f44.png",
......
/** /**
* Created by rockyl on 2020-01-21. * Created by rockyl on 2020-01-21.
*/ */
import {getTextureByName} from "./utils"; import { getTextureByName } from "./utils";
export class Background extends engine.Container { export class Background extends engine.Container {
private _bg: engine.Image; private _bg: engine.Image;
...@@ -13,21 +13,21 @@ export class Background extends engine.Container { ...@@ -13,21 +13,21 @@ export class Background extends engine.Container {
} }
setup() { setup() {
const {width, height} = this.stage; const { width, height } = this.stage;
let bg = this._bg = new engine.Image(getTextureByName('背景图')); let bg = this._bg = new engine.Image(getTextureByName('背景图'));
bg.anchorX = bg.width / 2; // bg.anchorX = bg.width / 2;
bg.anchorY = bg.height / 2; // bg.anchorY = bg.height / 2;
bg.x = -(bg.width - width) / 2; // bg.x = -(bg.width - width) / 2;
bg.y = -(bg.height - height) / 2; // bg.y = -(bg.height - height) / 2;
this.addChild(bg); this.addChild(bg);
this._minScale = width / bg.width; // this._minScale = width / bg.width;
} }
playZoom(type: 'in' | 'out', duration = 700) { playZoom(type: 'in' | 'out', duration = 700) {
return new Promise(resolve => { return new Promise(resolve => {
let scale = type === 'in' ? 1 : this._minScale; let scale = type === 'in' ? 1 : this._minScale;
engine.Tween.get(this._bg, null, null, true) engine.Tween.get(this._bg, null, null, true)
.to({scaleX: scale, scaleY: scale}, duration, engine.Ease.cubicInOut) .to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)
.call(resolve); .call(resolve);
}) })
} }
......
...@@ -3,65 +3,38 @@ ...@@ -3,65 +3,38 @@
* 障碍块 * 障碍块
*/ */
import {getBlockAsset,getBlockHitAsset,getTextureByName} from "./utils"; import { getBlockAsset, getTextureByName } from "./utils";
import {props} from "../props"; import { props } from "../props";
export default class Block extends engine.Container { export default class Block extends engine.Container {
private body: svga.Svga; private body: svga.Svga;
private bodyHit: svga.Svga;
private bodyProfect: svga.Svga;
type; type;
dir; dir;
constructor() { constructor() {
super(); super();
let body = this.body = new svga.Svga(); let body = this.body = new svga.Svga();
body.x = -props.blockWidth / 2; body.x = -props.blockWidth / 2;
body.y = -props.blockHitHeight - props.blockPaddingTop; body.y = -props.blockHitHeight - props.blockPaddingTop;
this.addChild(body); this.addChild(body);
let bodyHit = this.bodyHit = new svga.Svga();
bodyHit.x = -props.blockWidth / 2;
bodyHit.y = -props.blockHitHeight - props.blockPaddingTop+props.blockHitOffsetY;
this.addChild(bodyHit);
console.log("props.blockProfectOffset",props.blockProfectOffset)
let bodyProfect = this.bodyProfect = new svga.Svga();
bodyProfect.x = -props.blockWidth / 2+props.blockProfectOffset.x;
bodyProfect.y = -props.blockHitHeight - props.blockPaddingTop+props.blockProfectOffset.y;
this.addChild(bodyProfect);
} }
reset({type,}) { reset({ type, }) {
this.dir = Math.random() > 0.5 ? 1 : -1; this.dir = Math.random() > 0.5 ? 1 : -1;
if (this.type != type) {
this.type = type; this.type = type;
let asset = getBlockAsset(type); let asset = getBlockAsset();
this.body.source = 'asset://' + asset.uuid; this.body.source = 'asset://' + asset.uuid;
let assetHit = getBlockHitAsset(type);
console.log("assetHit",assetHit)
this.bodyHit.source = 'asset://' + assetHit.uuid;
}
this.bodyProfect.source = 'asset://' + engine.getAssetByName("完美方块素材").uuid;
this.scaleX = this.dir; this.scaleX = this.dir;
this.body.gotoAndStop(1); this.body.gotoAndStop(1);
this.bodyHit.gotoAndStop(1);
this.bodyProfect.gotoAndStop(1);
this.body.visible=true;
this.bodyHit.visible=false; this.body.visible = true;
} }
playEnter(index, animation) { playEnter(index, animation) {
...@@ -73,12 +46,12 @@ export default class Block extends engine.Container { ...@@ -73,12 +46,12 @@ export default class Block extends engine.Container {
return new Promise(resolve => { return new Promise(resolve => {
if (animation) { if (animation) {
engine.Tween.get(this, null, null, true) engine.Tween.get(this, null, null, true)
.to({x: 0,}, duration) .to({ x: 0, }, duration)
.call(resolve); .call(resolve);
} else { } else {
this.x = 0; this.x = 0;
setTimeout(() => { setTimeout(() => {
console.log(this.body); // console.log(this.body);
}, 200); }, 200);
resolve(); resolve();
} }
...@@ -97,25 +70,6 @@ export default class Block extends engine.Container { ...@@ -97,25 +70,6 @@ export default class Block extends engine.Container {
}, this); }, this);
} }
playHit() {
let bodyHit = this.bodyHit;
bodyHit.play(true, false);
this.body.visible=false;
this.bodyHit.visible=true;
bodyHit.once(engine.Event.END_FRAME, function () {
this.body.visible=true;
this.bodyHit.visible=false;
bodyHit.gotoAndStop(1);
}, this);
}
playProFect() {
let bodyProfect = this.bodyProfect;
bodyProfect.play(true, false);
bodyProfect.once(engine.Event.END_FRAME, function () {
bodyProfect.gotoAndStop(1);
}, this);
}
stop() { stop() {
engine.Tween.removeTweens(this); engine.Tween.removeTweens(this);
......
...@@ -64,6 +64,7 @@ export default class GameView extends engine.Container { ...@@ -64,6 +64,7 @@ export default class GameView extends engine.Container {
const {width, height} = this.stage; const {width, height} = this.stage;
const background = this.background = new Background(); const background = this.background = new Background();
background.y = height-1624;
this.addChild(background); this.addChild(background);
background.setup(); background.setup();
...@@ -74,22 +75,19 @@ export default class GameView extends engine.Container { ...@@ -74,22 +75,19 @@ export default class GameView extends engine.Container {
const guideLayer = this.guideLayer = new GuideLayer(); const guideLayer = this.guideLayer = new GuideLayer();
this.addChild(guideLayer); this.addChild(guideLayer);
const base = this.base = new Base();
frontContainer.addChild(base);
base.setup();
const blockContainer = this.blockContainer = new engine.Container(); const blockContainer = this.blockContainer = new engine.Container();
frontContainer.addChild(blockContainer); frontContainer.addChild(blockContainer);
const base = this.base = new Base();
frontContainer.addChild(base);
base.setup();
const player = this.player = new Player(); const player = this.player = new Player();
frontContainer.addChild(player); frontContainer.addChildAt(player,0);
player.setup(); player.setup();
player.addEventListener('jump-on-top', this.onPlayerJumpOnTop, this); player.addEventListener('jump-on-top', this.onPlayerJumpOnTop, this);
let scoreAddTipsContainer = this.scoreAddTipsContainer = new engine.Container(); let scoreAddTipsContainer = this.scoreAddTipsContainer = new engine.Container();
scoreAddTipsContainer.width=750; scoreAddTipsContainer.width=750;
scoreAddTipsContainer.anchorX = scoreAddTipsContainer.width / 2; scoreAddTipsContainer.anchorX = scoreAddTipsContainer.width / 2;
...@@ -106,9 +104,7 @@ export default class GameView extends engine.Container { ...@@ -106,9 +104,7 @@ export default class GameView extends engine.Container {
scoreAddTips.x = this.player.x-scoreAddTips.width / 2; scoreAddTips.x = this.player.x-scoreAddTips.width / 2;
scoreAddTipsContainer.addChild(scoreAddTips); scoreAddTipsContainer.addChild(scoreAddTips);
frontContainer.addChildAt(player,0);
frontContainer.addChild(player);
frontContainer.addChild(scoreAddTipsContainer); frontContainer.addChild(scoreAddTipsContainer);
...@@ -230,8 +226,6 @@ export default class GameView extends engine.Container { ...@@ -230,8 +226,6 @@ export default class GameView extends engine.Container {
addBlock(animation = true) { addBlock(animation = true) {
this.index++; this.index++;
const blockContainer = this.blockContainer; const blockContainer = this.blockContainer;
let block: Block; let block: Block;
...@@ -247,7 +241,8 @@ export default class GameView extends engine.Container { ...@@ -247,7 +241,8 @@ export default class GameView extends engine.Container {
block.reset({ block.reset({
type: Math.floor(Math.random() * props.blockAssets.length), type: Math.floor(Math.random() * props.blockAssets.length),
}); });
block.y = this.baseOffset - this.index * props.blockHitHeight+props.blockBaseOffset; console.log('addblock', this.index)
block.y = this.baseOffset - (this.index * props.blockHitHeight)+props.blockBaseOffset;
this.blockComplete = false; this.blockComplete = false;
block.playEnter(this.index, animation).then( block.playEnter(this.index, animation).then(
...@@ -349,11 +344,10 @@ export default class GameView extends engine.Container { ...@@ -349,11 +344,10 @@ export default class GameView extends engine.Container {
this.needHitTest = false; this.needHitTest = false;
clearInterval(this.timer); clearInterval(this.timer);
this.currentBlock.playHit();
// this.currentBlock.stop();
// this.playHitEffect(dir);
await this.player.hitAway(dir); await this.player.hitAway(dir);
// this.playZoom('out');
this.frontContainer.addChild(this.player);
await this.player.parachute(dir); await this.player.parachute(dir);
console.log('jump-high-game-end') console.log('jump-high-game-end')
...@@ -382,12 +376,10 @@ export default class GameView extends engine.Container { ...@@ -382,12 +376,10 @@ export default class GameView extends engine.Container {
} }
} }
if (type < 3) { if (type < 3) {
this.currentBlock.playEffect(); // this.currentBlock.playEffect();
} }
this.currentBlock.playEffect();
if(type===0){
this.currentBlock.playProFect();
}
if(type!=3){ if(type!=3){
} }
...@@ -395,7 +387,6 @@ export default class GameView extends engine.Container { ...@@ -395,7 +387,6 @@ export default class GameView extends engine.Container {
this.player.playLand(type, this.currentBlock.dir); this.player.playLand(type, this.currentBlock.dir);
this.currentBlock.stop(); this.currentBlock.stop();
this.scoreChange(type); this.scoreChange(type);
await this.playShake();
await new Promise(resolve => { await new Promise(resolve => {
engine.Tween.get(this, null, null, true) engine.Tween.get(this, null, null, true)
.to({pos: props.blockHitHeight * this.index}, 300, engine.Ease.cubicOut) .to({pos: props.blockHitHeight * this.index}, 300, engine.Ease.cubicOut)
...@@ -454,19 +445,4 @@ export default class GameView extends engine.Container { ...@@ -454,19 +445,4 @@ export default class GameView extends engine.Container {
.call(resolve); .call(resolve);
}) })
} }
playShake(){
const {x, y} = this.frontContainer;
return new Promise(resolve => {
const shakeOffset = 7;
const duration = 30;
engine.Tween.get(this.frontContainer, null, null, true)
.to({x: x, y: y - shakeOffset}, duration)
.to({x: x, y: y + shakeOffset}, duration)
.to({x: x + shakeOffset, y: y}, duration)
.to({x: x - shakeOffset, y: y}, duration)
.to({x: x, y: y}, duration)
.call(resolve)
})
}
} }
...@@ -2,19 +2,20 @@ ...@@ -2,19 +2,20 @@
* Created by rockyl on 2018/8/17. * Created by rockyl on 2018/8/17.
*/ */
import {props} from "../props"; import { props } from "../props";
import {createSvga, playSound,getTextureByName} from "./utils"; import { createSvga, playSound, getTextureByName } from "./utils";
const svgaAssets = { const svgaAssets = {
aniReady: {name: '准备立正', dir: 1}, aniReady: { name: '准备立正', dir: 1 },
aniReady2: {name: '准备立正', dir: 1}, aniReady2: { name: '准备立正', dir: 1 },
aniJump: {name: '跳上升', dir: 1}, aniJump: { name: '跳上升', dir: 1 },
aniFall: {name: '跳下落', dir: 1}, aniFall: { name: '跳下落', dir: 1 },
aniLandNormal: {name: '普通着地', dir: 1}, aniLandNormal: { name: '普通着地', dir: 1 },
aniLandSide: {name: '边缘着地', dir: -1}, aniLandSide: { name: '边缘着地', dir: -1 },
aniHit: {name: '被撞开', dir: -1}, aniHit: { name: '被撞开', dir: -1 },
aniParachute: {name: '降落', dir: -1}, // aniParachute: {name: '降落', dir: -1},
aniLandPerfect: {name: '完美着地_笑', dir: 1}, aniParachute: { name: '降落pic', dir: -1, type: 'pic' },
aniLandPerfect: { name: '完美着地_笑', dir: 1 },
}; };
export default class Player extends engine.Container { export default class Player extends engine.Container {
...@@ -58,9 +59,10 @@ export default class Player extends engine.Container { ...@@ -58,9 +59,10 @@ export default class Player extends engine.Container {
} }
let ani: svga.Svga = this._currentAni = this['ani' + name]; let ani: svga.Svga = this._currentAni = this['ani' + name];
this.addChild(ani); this.addChild(ani);
ani.y = -300;
if (play) { if (play) {
ani.play(false, loop); ani.play &&ani.play(false, loop);
if (loop) { if (loop) {
resolve(); resolve();
} else { } else {
...@@ -79,8 +81,18 @@ export default class Player extends engine.Container { ...@@ -79,8 +81,18 @@ export default class Player extends engine.Container {
this.landEffect = createSvga('着地特效', 'playerLandEffectAnchor'); this.landEffect = createSvga('着地特效', 'playerLandEffectAnchor');
for (let key in svgaAssets) { for (let key in svgaAssets) {
let {name, dir} = svgaAssets[key]; let body
let body = this[key] = createSvga(name, key.replace('ani', 'player') + 'Anchor'); let { name, dir, type } = svgaAssets[key];
if (type == 'pic') {
body = this[key] = new engine.Image(getTextureByName('降落pic'));
let anchor ={x: 75,y:122};
body.x = -anchor.x;
body.y = -anchor.y;
body.anchorX = anchor.x;
body.anchorY = anchor.y;
} else {
body = this[key] = createSvga(name, key.replace('ani', 'player') + 'Anchor');
}
body.name = 'body'; body.name = 'body';
body.scaleX = dir; body.scaleX = dir;
...@@ -94,7 +106,7 @@ export default class Player extends engine.Container { ...@@ -94,7 +106,7 @@ export default class Player extends engine.Container {
this._prefectLandCounting = 0; this._prefectLandCounting = 0;
engine.Tween.removeTweens(this); engine.Tween.removeTweens(this);
if(revive){ if (revive) {
this.switchAni('Jump', 1, false); this.switchAni('Jump', 1, false);
} }
} }
...@@ -103,7 +115,7 @@ export default class Player extends engine.Container { ...@@ -103,7 +115,7 @@ export default class Player extends engine.Container {
return new Promise(resolve => { return new Promise(resolve => {
this.switchAni('Ready', 1); this.switchAni('Ready', 1);
this._currentAni.once(engine.Event.END_FRAME, function () { this._currentAni.once(engine.Event.END_FRAME, function () {
this.switchAni('Ready2', 1, true,true); this.switchAni('Ready2', 1, true, true);
resolve(); resolve();
}, this); }, this);
}) })
...@@ -179,13 +191,13 @@ export default class Player extends engine.Container { ...@@ -179,13 +191,13 @@ export default class Player extends engine.Container {
this.removeChild(landEffect); this.removeChild(landEffect);
}, this); }, this);
await this.switchAni('LandPerfect'); await this.switchAni('LandPerfect');
await this.switchAni('Ready2', 1, true,true); await this.switchAni('Ready2', 1, true, true);
break; break;
case 1: case 1:
case 2: case 2:
this._prefectLandCounting = 0; this._prefectLandCounting = 0;
playSound('普通落地音效'); playSound('普通落地音效');
this.switchAni('Ready2', 1, true,true); this.switchAni('Ready2', 1, true, true);
break; break;
case 3: case 3:
this._prefectLandCounting = 0; this._prefectLandCounting = 0;
...@@ -226,8 +238,8 @@ export default class Player extends engine.Container { ...@@ -226,8 +238,8 @@ export default class Player extends engine.Container {
playSound('降落伞下落音效'); playSound('降落伞下落音效');
}) })
// .wait(300) // .wait(300)
.to({y: this.y + props.parachuteDistance}, props.parachuteDuration) .to({ y: this.y + props.parachuteDistance }, props.parachuteDuration)
.set({anchorOffsetY: 0}) .set({ anchorOffsetY: 0 })
.call(resolve) .call(resolve)
}); });
} }
......
...@@ -11,14 +11,10 @@ export function getTextureByName(name) { ...@@ -11,14 +11,10 @@ export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid); return getTexture(engine.getAssetByName(name).uuid);
} }
export function getBlockAsset(type) { export function getBlockAsset() {
return engine.getAssetByName(props.blockAssets[type]); return engine.getAssetByName(props.blockAssets[0]);
} }
export function getBlockHitAsset(type) {
console.log("props.blockHitAssets",props.blockHitAssets)
return engine.getAssetByName(props.blockHitAssets[type]);
}
export function createSvga(name, anchorName) { export function createSvga(name, anchorName) {
let inst = new svga.Svga(); let inst = new svga.Svga();
......
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