Commit 2added8b authored by Master Q's avatar Master Q

简单的做一个 tween 动画

parent 4fb8eb2f
...@@ -33,7 +33,15 @@ export class ParkourScene extends Scene { ...@@ -33,7 +33,15 @@ export class ParkourScene extends Scene {
const y = ParkourGameConfig.CommonConfig.GamerAxisY const y = ParkourGameConfig.CommonConfig.GamerAxisY
const x = (y - b) / k const x = (y - b) / k
this.NewContIns.setPosition(x, y) this.NewContIns.fy = y
// 简单的做一个 tween 动画吧
FYGE.Tween.removeTweens(this.NewContIns)
FYGE.Tween.get(this.NewContIns)
.to({
fx: x
}, 300, FYGE.Ease.quadInOut)
// this.NewContIns.setPosition(x, y)
} }
} }
...@@ -78,10 +86,18 @@ export class ParkourScene extends Scene { ...@@ -78,10 +86,18 @@ export class ParkourScene extends Scene {
this.stage.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, this.onGameDetermineMouseDown, this) this.stage.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, this.onGameDetermineMouseDown, this)
} }
/**
* 碰撞检测
* @param e
*/
onGameEleCollision(e: FYGE.Event) { onGameEleCollision(e: FYGE.Event) {
console.log(e.data) console.log(e.data)
} }
/**
* 游戏左右滑动的 检测
* @param e
*/
onGameDetermineMouseDown(e: FYGE.MouseEvent) { onGameDetermineMouseDown(e: FYGE.MouseEvent) {
const startPos = { const startPos = {
x: e.stageX, x: e.stageX,
...@@ -95,6 +111,9 @@ export class ParkourScene extends Scene { ...@@ -95,6 +111,9 @@ export class ParkourScene extends Scene {
}) })
} }
/**
* 游戏帧事件
*/
onEnterFrame() { onEnterFrame() {
this.conBeltList.forEach(it => { this.conBeltList.forEach(it => {
if (it.isMoving) { if (it.isMoving) {
...@@ -115,6 +134,10 @@ export class ParkourScene extends Scene { ...@@ -115,6 +134,10 @@ export class ParkourScene extends Scene {
}) })
} }
/**
* 测试用的
* @param e
*/
onMouseDown(e: FYGE.MouseEvent) { onMouseDown(e: FYGE.MouseEvent) {
const startPos = { const startPos = {
x: e.stageX, x: e.stageX,
......
...@@ -43,13 +43,29 @@ export class ConveyorBeltItem extends FYGE.Container { ...@@ -43,13 +43,29 @@ export class ConveyorBeltItem extends FYGE.Container {
this.visible = true this.visible = true
} }
get fx() {
return this._x
}
set fx(v) {
this._x = v
this.x = this._x - (this.propsData.anchorX || 0)
}
get fy() {
return this._y
}
set fy(v) {
this._y = v
this.y = this._y - (this.propsData.anchorY || 0)
}
_x: number = 0 // should be x axis value _x: number = 0 // should be x axis value
_y: number = 0 _y: number = 0
setPosition(x: number, y: number) { setPosition(x: number, y: number) {
this._x = x this.fx = x
this._y = y this.fy = y
this.x = this._x - (this.propsData.anchorX || 0)
this.y = this._y - (this.propsData.anchorY || 0)
} }
/** /**
...@@ -132,6 +148,16 @@ export class ConveyorBelt extends FYGE.Container { ...@@ -132,6 +148,16 @@ export class ConveyorBelt extends FYGE.Container {
this.totalDisY = Math.abs(props.startPos.y - props.endPos.y) this.totalDisY = Math.abs(props.startPos.y - props.endPos.y)
this.clockIns = new Clock() this.clockIns = new Clock()
if (ParkourGameConfig.CommonConfig.CollisionDebug) {
const a = UI.Shape(this)
.closePath()
.beginStroke(0x00ff00)
.lineTo(props.startPos.x, props.startPos.y)
.lineTo(props.endPos.x, props.endPos.y)
.endStroke()
.closePath()
}
this.initEvents() this.initEvents()
} }
......
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