Commit c05d2240 authored by Master Q's avatar Master Q

动效完善

parent ee62695e
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1) canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1)
canvas.height = document.body.clientHeight * (window.devicePixelRatio || 1) canvas.height = document.body.clientHeight * (window.devicePixelRatio || 1)
new Main(canvas, { new Main(canvas, {
isFirstGame: true isFirstGame: false
}) })
}) })
......
...@@ -11,6 +11,14 @@ ...@@ -11,6 +11,14 @@
{ {
"keys": "closebtn.png,giftBoxIcon.png,waitingBg.png,waitingRot.png", "keys": "closebtn.png,giftBoxIcon.png,waitingBg.png,waitingRot.png",
"name": "common" "name": "common"
},
{
"keys": "rabbit0.spi",
"name": "spine"
},
{
"keys": "SpBoom.svga,boomSvga.svga,spSvga.svga",
"name": "svga"
} }
], ],
"path": "./resource/" "path": "./resource/"
......
tuzi跳.png 人物.png
size: 256,256 size: 256,256
format: RGBA8888 format: RGBA8888
filter: Linear,Linear filter: Linear,Linear
repeat: none repeat: none
erdy arm l
rotate: true rotate: false
xy: 112, 120 xy: 226, 154
size: 49, 65 size: 23, 49
orig: 69, 81 orig: 23, 49
offset: 0, 1 offset: 0, 0
index: -1 index: -1
erdz arm r
rotate: false rotate: false
xy: 95, 31 xy: 226, 205
size: 36, 78 size: 28, 49
orig: 36, 94 orig: 28, 50
offset: 0, 1 offset: 0, 0
index: -1 index: -1
jb body
rotate: false rotate: false
xy: 133, 13 xy: 161, 206
size: 38, 38 size: 63, 48
orig: 39, 42 orig: 63, 49
offset: 0, 3 offset: 0, 0
index: -1 index: -1
st ear l
rotate: false rotate: false
xy: 2, 111 xy: 97, 201
size: 108, 136 size: 62, 53
orig: 138, 139 orig: 62, 53
offset: 26, 2 offset: 0, 0
index: -1 index: -1
toua ear r
rotate: true
xy: 161, 160
size: 44, 63
orig: 44, 63
offset: 0, 0
index: -1
eye l
rotate: false rotate: false
xy: 2, 21 xy: 122, 145
size: 91, 88 size: 24, 20
orig: 94, 89 orig: 26, 22
offset: 3, 1 offset: 1, 1
index: -1 index: -1
weib eye r
rotate: false rotate: false
xy: 220, 100 xy: 97, 144
size: 27, 29 size: 23, 21
orig: 31, 33 orig: 25, 23
offset: 2, 2 offset: 1, 1
index: -1
eye sadl
rotate: true
xy: 33, 126
size: 18, 23
orig: 18, 23
offset: 0, 0
index: -1
eye sadr
rotate: true
xy: 2, 125
size: 18, 23
orig: 18, 23
offset: 0, 0
index: -1
eye xiaol
rotate: true
xy: 148, 146
size: 19, 11
orig: 19, 11
offset: 0, 0
index: -1
eye xiaor
rotate: true
xy: 79, 125
size: 19, 11
orig: 19, 11
offset: 0, 0
index: -1
eyebrow l
rotate: false
xy: 45, 111
size: 8, 5
orig: 10, 8
offset: 1, 1
index: -1 index: -1
ys eyebrow r
rotate: false rotate: false
xy: 133, 53 xy: 45, 118
size: 36, 65 size: 7, 6
orig: 39, 69 orig: 10, 8
offset: 1, 3 offset: 2, 1
index: -1 index: -1
yziz face
rotate: false rotate: false
xy: 112, 171 xy: 2, 174
size: 135, 76 size: 93, 80
orig: 176, 107 orig: 93, 81
offset: 27, 17 offset: 0, 0
index: -1 index: -1
zs foot l
rotate: true rotate: true
xy: 179, 131 xy: 138, 167
size: 38, 65 size: 32, 21
orig: 41, 67 orig: 33, 22
offset: 1, 1 offset: 1, 0
index: -1
leg l
rotate: true
xy: 97, 167
size: 32, 39
orig: 32, 39
offset: 0, 0
index: -1
mouth
rotate: false
xy: 58, 116
size: 17, 11
orig: 17, 19
offset: 0, 8
index: -1
mouth sad
rotate: false
xy: 27, 113
size: 16, 11
orig: 16, 12
offset: 0, 1
index: -1 index: -1
zsy mouth smile
rotate: true rotate: true
xy: 179, 98 xy: 58, 129
size: 31, 39 size: 15, 19
orig: 36, 42 orig: 15, 19
offset: 3, 1 offset: 0, 0
index: -1
sai l
rotate: false
xy: 33, 146
size: 30, 26
orig: 34, 30
offset: 2, 2
index: -1
sai r
rotate: false
xy: 65, 146
size: 30, 26
orig: 34, 30
offset: 2, 2
index: -1
tail
rotate: false
xy: 2, 145
size: 29, 27
orig: 29, 27
offset: 0, 0
index: -1 index: -1
This source diff could not be displayed because it is too large. You can view the blob instead.
scripts/rabbit/rabbit.png

69.7 KB | W: | H:

scripts/rabbit/rabbit.png

42 KB | W: | H:

scripts/rabbit/rabbit.png
scripts/rabbit/rabbit.png
scripts/rabbit/rabbit.png
scripts/rabbit/rabbit.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -108,6 +108,9 @@ export function createElement<K extends new(p?: any) => ChildType, T extends Chi ...@@ -108,6 +108,9 @@ export function createElement<K extends new(p?: any) => ChildType, T extends Chi
if (isFunction(props.onAddedToStage)) { if (isFunction(props.onAddedToStage)) {
eleins.addEventListener(FYGE.Event.ADDED_TO_STAGE, props.onAddedToStage!) eleins.addEventListener(FYGE.Event.ADDED_TO_STAGE, props.onAddedToStage!)
} }
if (isFunction(props.onRemoveFromStage)) {
eleins.addEventListener(FYGE.Event.REMOVED_FROM_STAGE, props.onRemoveFromStage)
}
// 被移除的时候直接 去 清除 Tween // 被移除的时候直接 去 清除 Tween
eleins.addEventListener(FYGE.Event.REMOVED_FROM_STAGE, function(e: any) { eleins.addEventListener(FYGE.Event.REMOVED_FROM_STAGE, function(e: any) {
......
...@@ -7,5 +7,7 @@ export type EventsMap = { ...@@ -7,5 +7,7 @@ export type EventsMap = {
onClickCapture?: EventCallBack<FYGE.MouseEvent> onClickCapture?: EventCallBack<FYGE.MouseEvent>
onEnterFrame?: EventCallBack<FYGE.Event> onEnterFrame?: EventCallBack<FYGE.Event>
onAddedToStage?: EventCallBack<FYGE.Event> onAddedToStage?: EventCallBack<FYGE.Event>,
onRemoveFromStage?: EventCallBack<FYGE.Event>
} }
\ No newline at end of file
...@@ -2,188 +2,24 @@ export const ResJson = { ...@@ -2,188 +2,24 @@ export const ResJson = {
"groups": [ "groups": [
{ {
"keys": "GSB.png,clockBack.png,platform.png,rabbit.png,scoreBoardBack.png,sp_boom.png,sp_milk.png", "keys": "GSB.png,clockBack.png,platform.png,rabbit.png,scoreBoardBack.png,sp_boom.png,sp_milk.png",
"name": "GameScene", "name": "GameScene"
"atlas": {
"GSB.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 1624,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 1624,
"ro": false
},
"rabbit.png": {
"x": 754,
"y": 2,
"w": 110,
"h": 218,
"ox": 0,
"oy": 0,
"sw": 110,
"sh": 218,
"ro": false
},
"scoreBoardBack.png": {
"x": 754,
"y": 222,
"w": 193,
"h": 81,
"ox": 0,
"oy": 0,
"sw": 193,
"sh": 81,
"ro": true
},
"platform.png": {
"x": 754,
"y": 417,
"w": 142,
"h": 52,
"ox": 0,
"oy": 0,
"sw": 142,
"sh": 52,
"ro": true
},
"sp_boom.png": {
"x": 754,
"y": 561,
"w": 94,
"h": 99,
"ox": 0,
"oy": 0,
"sw": 94,
"sh": 99,
"ro": true
},
"sp_milk.png": {
"x": 754,
"y": 657,
"w": 93,
"h": 93,
"ox": 0,
"oy": 0,
"sw": 93,
"sh": 93,
"ro": false
},
"clockBack.png": {
"x": 754,
"y": 752,
"w": 80,
"h": 91,
"ox": 0,
"oy": 0,
"sw": 80,
"sh": 91,
"ro": true
}
}
}, },
{ {
"keys": "Guide1.png,Guide2.png,Guide3.png,Guide4.png", "keys": "Guide1.png,Guide2.png,Guide3.png,Guide4.png",
"name": "NewGuyScene", "name": "NewGuyScene"
"atlas": {
"Guide1.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 1624,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 1624,
"ro": false
},
"Guide2.png": {
"x": 754,
"y": 2,
"w": 750,
"h": 1624,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 1624,
"ro": false
},
"Guide3.png": {
"x": 1506,
"y": 2,
"w": 750,
"h": 1624,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 1624,
"ro": false
},
"Guide4.png": {
"x": 2,
"y": 1628,
"w": 750,
"h": 1624,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 1624,
"ro": true
}
}
}, },
{ {
"keys": "closebtn.png,giftBoxIcon.png,waitingBg.png,waitingRot.png", "keys": "closebtn.png,giftBoxIcon.png,waitingBg.png,waitingRot.png",
"name": "common", "name": "common"
"atlas": { },
"waitingBg.png": { {
"x": 2, "keys": "rabbit0.spi",
"y": 2, "name": "spine"
"w": 160, },
"h": 180, {
"ox": 0, "keys": "SpBoom.svga,boomSvga.svga,spSvga.svga",
"oy": 0, "name": "svga"
"sw": 160,
"sh": 180,
"ro": false
},
"giftBoxIcon.png": {
"x": 164,
"y": 2,
"w": 127,
"h": 125,
"ox": 0,
"oy": 0,
"sw": 127,
"sh": 125,
"ro": true
},
"waitingRot.png": {
"x": 2,
"y": 184,
"w": 56,
"h": 56,
"ox": 0,
"oy": 0,
"sw": 56,
"sh": 56,
"ro": false
},
"closebtn.png": {
"x": 60,
"y": 184,
"w": 52,
"h": 52,
"ox": 0,
"oy": 0,
"sw": 52,
"sh": 52,
"ro": false
}
}
} }
], ],
// eslint-disable-next-line "path": "./resource/"
"path": "https://yun.duiba.com.cn/db_games/activity/template/1670923535/resource/"
} }
\ No newline at end of file
import { OriginalElementWidthEvents } from "../../Dream";
export const DreamSvgaAni: OriginalElementWidthEvents<{
svgaData: any,
loop?: number,
loopEnd?: () => void
}, FYGE.SvgaAni> = ({
svgaData,
loop = 0,
loopEnd = () => {}
}) => {
const svgaIns = new FYGE.SvgaAni(svgaData)
svgaIns.play(loop, loopEnd)
return svgaIns
}
\ No newline at end of file
...@@ -14,8 +14,8 @@ export const GameConfig = { ...@@ -14,8 +14,8 @@ export const GameConfig = {
mapChangeAddSpeed: 10, // 切换地图就会 增加速度 mapChangeAddSpeed: 10, // 切换地图就会 增加速度
renderMapScreenNum: 200, //当卷轴 移动到视窗上面多少 会去生成地图 renderMapScreenNum: 200, //当卷轴 移动到视窗上面多少 会去生成地图
rabbitConfig: { rabbitConfig: {
offsetX: 10, offsetX: 70,
offsetY: -203, offsetY: 30,
}, },
DecisionLine: [ DecisionLine: [
// 判定线 当前屏幕显示区域 // 判定线 当前屏幕显示区域
...@@ -37,7 +37,7 @@ export const GameConfig = { ...@@ -37,7 +37,7 @@ export const GameConfig = {
[4, 0, 0, 5, 0], [4, 0, 0, 5, 0],
[0, 1, 1, 0, 1], [0, 1, 1, 0, 1],
[4, 3, 0, 1, 0], [4, 3, 0, 1, 0],
[0, 1, 1, 0, 0], [0, 1, 1, 1, 0],
[5, 0, 0, 0, 1], [5, 0, 0, 0, 1],
[1, 0, 1, 1, 1], [1, 0, 1, 1, 1],
[0, 1, 0, 0, 5], [0, 1, 0, 0, 5],
......
...@@ -10,7 +10,7 @@ import { PromiseAwait } from "../../tools/Tools"; ...@@ -10,7 +10,7 @@ import { PromiseAwait } from "../../tools/Tools";
import { GameConfig } from "./GameConfig"; import { GameConfig } from "./GameConfig";
import { G_Events } from "./GameEvents"; import { G_Events } from "./GameEvents";
import { Platform } from "./Platform"; import { Platform } from "./Platform";
import { RabbitPlayer } from "./Player"; import { PlayerIns, RabbitActionMap, RabbitPlayer } from "./Player";
import { ScoreBoard } from "./ScoreBoard"; import { ScoreBoard } from "./ScoreBoard";
import { SpClock } from "./SpClock"; import { SpClock } from "./SpClock";
...@@ -31,6 +31,8 @@ function randomPro(n: number) { ...@@ -31,6 +31,8 @@ function randomPro(n: number) {
@UsePreload({ @UsePreload({
preAction: async function() { preAction: async function() {
await RES.loadGroup('GameScene') await RES.loadGroup('GameScene')
await RES.loadGroup('spine')
await RES.loadGroup('svga')
} }
}) })
export class GameScene extends Dream.RenderContainer { export class GameScene extends Dream.RenderContainer {
...@@ -46,7 +48,6 @@ export class GameScene extends Dream.RenderContainer { ...@@ -46,7 +48,6 @@ export class GameScene extends Dream.RenderContainer {
set mapCount(v) { set mapCount(v) {
this._mapCount = v; this._mapCount = v;
this.renderMapOffsetY = layers.stageOffsetY - GameConfig.renderMapScreenNum + (v - 1) * mapHeight this.renderMapOffsetY = layers.stageOffsetY - GameConfig.renderMapScreenNum + (v - 1) * mapHeight
console.log('renderMapOffsetY:', this.renderMapOffsetY)
} }
isPause: boolean = true isPause: boolean = true
...@@ -58,6 +59,9 @@ export class GameScene extends Dream.RenderContainer { ...@@ -58,6 +59,9 @@ export class GameScene extends Dream.RenderContainer {
SpClockIns: SpClock // 道具倒计时 SpClockIns: SpClock // 道具倒计时
double: number = 1 // 是否双倍 double: number = 1 // 是否双倍
rabbitIns: PlayerIns
cloneRabbitIns: PlayerIns
set dir(v: number) { set dir(v: number) {
this.rabbitContainer.scaleX = v this.rabbitContainer.scaleX = v
this.rabbitCloneContainer.scaleX = v this.rabbitCloneContainer.scaleX = v
...@@ -114,19 +118,28 @@ export class GameScene extends Dream.RenderContainer { ...@@ -114,19 +118,28 @@ export class GameScene extends Dream.RenderContainer {
* 游戏结束 * 游戏结束
*/ */
onGameOver() { onGameOver() {
this.onShowRabbitAni(RabbitActionMap.Fail)
FYGE.Tween.removeTweens(this.rabbitContainer) FYGE.Tween.removeTweens(this.rabbitContainer)
this.isPause = true this.isPause = true
GDispatcher.dispatchEvent(G_Events.GameOver, this.ScoreBoardIns.score) GDispatcher.dispatchEvent(G_Events.GameOver, this.ScoreBoardIns.score)
} }
/**
* 显示动画
*/
onShowRabbitAni(aniName: RabbitActionMap, endAni?: RabbitActionMap) {
this.rabbitIns.showAni(aniName, endAni)
this.cloneRabbitIns.showAni(aniName, endAni)
}
/** /**
* 开始渲染地图 * 开始渲染地图
* @param init 是否是初始化 * @param init 是否是初始化
*/ */
renderMap(init: boolean = false) { renderMap(init: boolean = false) {
console.info('=========render map ===========') console.info('=========render map ===========')
const mapConfig = GameConfig.mapList[Math.random() * GameConfig.mapList.length >> 0] const mapConfig = GameConfig.mapList[Math.random() * GameConfig.mapList.length >> 0]
const { const {
rowNum, rowNum,
...@@ -142,7 +155,10 @@ export class GameScene extends Dream.RenderContainer { ...@@ -142,7 +155,10 @@ export class GameScene extends Dream.RenderContainer {
// 地图平台数组 // 地图平台数组
const mapPlatform:Platform[][] = [] const mapPlatform:Platform[][] = []
this.GameMapContainer.addChildAt( this.GameMapContainer.addChildAt(
<DreamContainer className="mapContainer" inlineProps={{ <DreamContainer className="mapContainer" onRemoveFromStage={() => {
console.log(this.rabbitBoxMap)
console.log('remove!!!!')
}} inlineProps={{
y: this.mapCount * rowNum * offsetYLen * -1 y: this.mapCount * rowNum * offsetYLen * -1
}}> }}>
{ {
...@@ -198,9 +214,16 @@ export class GameScene extends Dream.RenderContainer { ...@@ -198,9 +214,16 @@ export class GameScene extends Dream.RenderContainer {
</DreamContainer> </DreamContainer>
, 0) , 0)
this.mapCount += 1 this.mapCount += 1
// 增加速度 // 增加速度
GameConfig.speed += GameConfig.mapChangeAddSpeed GameConfig.speed += GameConfig.mapChangeAddSpeed
this.rabbitBoxMap.unshift(...mapPlatform) this.rabbitBoxMap.unshift(...mapPlatform)
// 第三章图片的话,清楚掉第一张地图
if (this.mapCount >= 3) {
this.rabbitBoxMap.splice(60)
this.GameMapContainer.removeChildAt(2)
}
} }
/** /**
...@@ -210,9 +233,12 @@ export class GameScene extends Dream.RenderContainer { ...@@ -210,9 +233,12 @@ export class GameScene extends Dream.RenderContainer {
*/ */
renderRabbit(pos: Pos) { renderRabbit(pos: Pos) {
if (this.rabbitContainer) return if (this.rabbitContainer) return
// TODO Player 动作集 this.rabbitContainer = this.GameMapContainer.addChild(<RabbitPlayer getPlayer={p => {
this.rabbitContainer = this.GameMapContainer.addChild(<RabbitPlayer />) this.rabbitIns = p
this.rabbitCloneContainer = this.GameMapContainer.addChild(<RabbitPlayer inlineProps={{ }} />)
this.rabbitCloneContainer = this.GameMapContainer.addChild(<RabbitPlayer getPlayer={p => {
this.cloneRabbitIns = p
}} inlineProps={{
visible: false, visible: false,
className: 'clone' className: 'clone'
}} />) }} />)
...@@ -221,7 +247,6 @@ export class GameScene extends Dream.RenderContainer { ...@@ -221,7 +247,6 @@ export class GameScene extends Dream.RenderContainer {
pos.y * offsetYLen pos.y * offsetYLen
) )
this.rabbitPos = pos this.rabbitPos = pos
console.log(this.rabbitContainer)
} }
lastTime: number = 0 lastTime: number = 0
...@@ -279,15 +304,25 @@ export class GameScene extends Dream.RenderContainer { ...@@ -279,15 +304,25 @@ export class GameScene extends Dream.RenderContainer {
let landPlatform: Platform let landPlatform: Platform
while(!(landPlatform = rabbitBoxMap[shouldY][willX])) { while(!(landPlatform = rabbitBoxMap[shouldY][willX])) {
shouldY += 1 shouldY += 1
if (shouldY >= rabbitBoxMap.length - 1) { if (shouldY >= rabbitBoxMap.length) {
break break
} }
} }
// TODO 如果找不到 下去的平台 直接不让跳吧
if (!landPlatform) {
resolve()
return
}
// 这里之前提前改,否则会有时序问题 // 这里之前提前改,否则会有时序问题
this.rabbitPos = { this.rabbitPos = {
x: willX, x: willX,
y: shouldY y: shouldY
} }
const afterCb = this.onPlatformLand(landPlatform)
FYGE.Tween.removeTweens(rabbitContainer) FYGE.Tween.removeTweens(rabbitContainer)
if (rax == 4) { if (rax == 4) {
rabbitCloneContainer.visible = true rabbitCloneContainer.visible = true
...@@ -297,7 +332,7 @@ export class GameScene extends Dream.RenderContainer { ...@@ -297,7 +332,7 @@ export class GameScene extends Dream.RenderContainer {
rabbitCloneContainer.position.set(rabbitContainer.x + 750, rabbitContainer.y) rabbitCloneContainer.position.set(rabbitContainer.x + 750, rabbitContainer.y)
} }
const sp = shouldY - ray const sp = shouldY - ray
const downTime = 200 * (sp > 0 ? sp : 1) const downTime = 300 // 200 * (sp > 0 ? sp : 1)
FYGE.Tween.get(rabbitContainer, { FYGE.Tween.get(rabbitContainer, {
onChange: () => { onChange: () => {
// rabbitContainer.x = (rabbitContainer.x + 750) % 750 // rabbitContainer.x = (rabbitContainer.x + 750) % 750
...@@ -306,7 +341,7 @@ export class GameScene extends Dream.RenderContainer { ...@@ -306,7 +341,7 @@ export class GameScene extends Dream.RenderContainer {
}) })
.to({ .to({
x: _willX * offsetXLen x: _willX * offsetXLen
}, 400 + downTime) }, 600 + downTime)
FYGE.Tween.get(rabbitContainer, { FYGE.Tween.get(rabbitContainer, {
onChange: () => { onChange: () => {
...@@ -315,7 +350,7 @@ export class GameScene extends Dream.RenderContainer { ...@@ -315,7 +350,7 @@ export class GameScene extends Dream.RenderContainer {
}) })
.to({ .to({
y: Math.min(ry + sp * offsetYLen, ry) - 100 y: Math.min(ry + sp * offsetYLen, ry) - 100
}, 400, FYGE.Ease.quadOut) }, 600, FYGE.Ease.quadOut)
.to({ .to({
y: ry + sp * offsetYLen y: ry + sp * offsetYLen
}, downTime, FYGE.Ease.quadIn) }, downTime, FYGE.Ease.quadIn)
...@@ -326,7 +361,8 @@ export class GameScene extends Dream.RenderContainer { ...@@ -326,7 +361,8 @@ export class GameScene extends Dream.RenderContainer {
this.rabbitContainer = rabbitCloneContainer this.rabbitContainer = rabbitCloneContainer
this.rabbitCloneContainer = rabbitContainer this.rabbitCloneContainer = rabbitContainer
} }
this.onPlatformLand(landPlatform)
afterCb()
resolve() resolve()
}) })
...@@ -338,17 +374,34 @@ export class GameScene extends Dream.RenderContainer { ...@@ -338,17 +374,34 @@ export class GameScene extends Dream.RenderContainer {
* @param platform * @param platform
*/ */
onPlatformLand(platform: Platform) { onPlatformLand(platform: Platform) {
platform.onLand((type: number, s: number) => { let noop = () => {}
platform.onLand((type: number, s: number, cb: Function) => {
// pre 去做动作吧
if (type == 3) { if (type == 3) {
return this.onGameOver() this.onShowRabbitAni(RabbitActionMap.Jump, RabbitActionMap.Fail)
} else if (type == 2) { } else if (type == 2) {
this.double = 2 this.onShowRabbitAni(RabbitActionMap.Jump, RabbitActionMap.Smile)
this.SpClockIns.onShowCountDown(() => { } else {
this.double = 1 this.onShowRabbitAni(RabbitActionMap.Jump, RabbitActionMap.Normal)
}) }
// 落地的回调
noop = () => {
cb()
if (type == 3) {
return this.onGameOver()
} else if (type == 2) {
this.double = 2
this.SpClockIns.onShowCountDown(() => {
this.double = 1
})
}
this.onAddScore(s)
} }
this.onAddScore(s)
}) })
return noop
} }
/** /**
......
import { DreamContainer } from "../../components/DreamContainer/DreamContainer"; import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamSprite } from "../../components/DreamSprite/DreamSprite"; import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import { DreamSvgaAni } from "../../components/DreamSvgaAni/DreamSvgaAni";
import { DreamTextField } from "../../components/DreamTextField/DreamTextField"; import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
import Dream from "../../Dream"; import Dream from "../../Dream";
import { fadeOutUpFactory } from "../../modules/animations"; import { fadeOutUpFactory } from "../../modules/animations";
...@@ -13,13 +14,36 @@ export class Platform extends Dream.RenderContainer<{ ...@@ -13,13 +14,36 @@ export class Platform extends Dream.RenderContainer<{
}> { }> {
private isLanded: boolean = false // 是否被踩过 private isLanded: boolean = false // 是否被踩过
private spCont: FYGE.Container private spCont: FYGE.Container
onLand(cb?: (type: number, s: number) => void) { PlatformContainer: FYGE.Container
if (this.isLanded) return onLand(cb?: (type: number, s: number, afterCb: Function) => void) {
const ctype = this.isLanded ? 1 : this.props.type
cb && cb(ctype, this.isLanded ? 0 : GameConfig.landPlatformScore, () => {
if (ctype !== 1 && this.spCont) {
// fadeOutUpFactory(500)(this.spCont)
this.spCont.visible = false
if (ctype == 3) {
const atom = new FYGE.SvgaAni(RES.getRes('boomSvga.svga'))
atom.position.set(-50, -162)
atom.play(1, () => {
atom.parent.removeChild(atom)
})
this.PlatformContainer.addChild(
atom
)
} else if (ctype == 2) {
const atom = new FYGE.SvgaAni(RES.getRes('spSvga.svga'))
atom.position.set(-100, -320)
atom.play(1, () => {
atom.parent.removeChild(atom)
})
this.PlatformContainer.addChild(
atom
)
}
}
})
this.isLanded = true this.isLanded = true
if (this.spCont) {
fadeOutUpFactory(500)(this.spCont)
}
cb && cb(this.props.type, GameConfig.landPlatformScore)
} }
/** /**
...@@ -33,17 +57,21 @@ export class Platform extends Dream.RenderContainer<{ ...@@ -33,17 +57,21 @@ export class Platform extends Dream.RenderContainer<{
y: -100 y: -100
}} src={RES.getRes('sp_milk.png')} /> }} src={RES.getRes('sp_milk.png')} />
} else if (this.props.type == 3) { } else if (this.props.type == 3) {
return this.spCont = <DreamSprite inlineProps={{ return this.spCont = <DreamSvgaAni
x: 20, inlineProps={{
y: -90 x: 20,
}} src={RES.getRes('sp_boom.png')} /> y: -85
}}
svgaData={RES.getRes('SpBoom.svga')} />
} }
} }
render() { render() {
const backRes = RES.getRes('platform.png') const backRes = RES.getRes('platform.png')
return ( return (
<DreamContainer inlineProps={{ <DreamContainer ref={el => {
this.PlatformContainer = el
}} inlineProps={{
x: this.props.x || 0 x: this.props.x || 0
}}> }}>
<DreamSprite src={backRes} inlineProps={{ <DreamSprite src={backRes} inlineProps={{
......
import { DreamContainer } from "../../components/DreamContainer/DreamContainer"; import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamSpine, setSpineAni } from "../../components/DreamSpine/DreamSpine";
import { DreamSprite } from "../../components/DreamSprite/DreamSprite"; import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import Dream from "../../Dream"; import Dream from "../../Dream";
import { RES } from "../../modules/RES"; import { RES } from "../../modules/RES";
import { Tools } from "../../tools/Tools";
import { GameConfig } from "./GameConfig"; import { GameConfig } from "./GameConfig";
export enum RabbitActionMap {
Normal = 'daijizc',
Smile = 'daijizcxiao',
Fail = 'daijiku',
Jump = 'jump'
}
export type PlayerIns = {
showAni: (a: RabbitActionMap, b?: RabbitActionMap) => Promise<any>
}
export class RabbitPlayer extends Dream.RenderContainer<{ export class RabbitPlayer extends Dream.RenderContainer<{
inlineProps?: Record<string, any> inlineProps?: Record<string, any>,
getPlayer?: (p: PlayerIns) => void
}> { }> {
spinePlayer: FYGE.Spine
currAniName: RabbitActionMap
didRendered(): void {
this.props.getPlayer && this.props.getPlayer({
showAni: (aniName: RabbitActionMap, endAni?: RabbitActionMap) => {
this.currAniName = aniName
return new Promise<void>(resolve => {
setSpineAni(this.spinePlayer, aniName, endAni ? 1 : 0, () => {
endAni && setSpineAni(this.spinePlayer, endAni)
resolve()
})
})
}
})
}
render() { render() {
const spineData = RES.getRes('rabbit0.spi')
return ( return (
<DreamContainer inlineProps={{ <DreamContainer inlineProps={{
...this.props.inlineProps, ...this.props.inlineProps,
...@@ -17,7 +50,13 @@ export class RabbitPlayer extends Dream.RenderContainer<{ ...@@ -17,7 +50,13 @@ export class RabbitPlayer extends Dream.RenderContainer<{
x: GameConfig.rabbitConfig.offsetX, x: GameConfig.rabbitConfig.offsetX,
y: GameConfig.rabbitConfig.offsetY y: GameConfig.rabbitConfig.offsetY
}}> }}>
<DreamSprite src={RES.getRes('rabbit.png')} /> {/* <DreamSprite src={RES.getRes('rabbit.png')} /> */}
<DreamSpine ref={el => {
this.spinePlayer = el
}} spineData={spineData}
aniName={"daijizc"}
skinName={Tools.PageData.skinName}
/>
</DreamContainer> </DreamContainer>
</DreamContainer> </DreamContainer>
) )
......
export class Tools { export class Tools {
static PageData: { static PageData: {
isFirstGame: boolean isFirstGame: boolean
skinName: string
} = { } = {
isFirstGame: false isFirstGame: false,
skinName: ''
} }
} }
......
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