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

简单的做一个 tween 动画

parent 4fb8eb2f
......@@ -33,7 +33,15 @@ export class ParkourScene extends Scene {
const y = ParkourGameConfig.CommonConfig.GamerAxisY
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 {
this.stage.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, this.onGameDetermineMouseDown, this)
}
/**
* 碰撞检测
* @param e
*/
onGameEleCollision(e: FYGE.Event) {
console.log(e.data)
}
/**
* 游戏左右滑动的 检测
* @param e
*/
onGameDetermineMouseDown(e: FYGE.MouseEvent) {
const startPos = {
x: e.stageX,
......@@ -95,6 +111,9 @@ export class ParkourScene extends Scene {
})
}
/**
* 游戏帧事件
*/
onEnterFrame() {
this.conBeltList.forEach(it => {
if (it.isMoving) {
......@@ -115,6 +134,10 @@ export class ParkourScene extends Scene {
})
}
/**
* 测试用的
* @param e
*/
onMouseDown(e: FYGE.MouseEvent) {
const startPos = {
x: e.stageX,
......
......@@ -43,13 +43,29 @@ export class ConveyorBeltItem extends FYGE.Container {
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
_y: number = 0
setPosition(x: number, y: number) {
this._x = x
this._y = y
this.x = this._x - (this.propsData.anchorX || 0)
this.y = this._y - (this.propsData.anchorY || 0)
this.fx = x
this.fy = y
}
/**
......@@ -132,6 +148,16 @@ export class ConveyorBelt extends FYGE.Container {
this.totalDisY = Math.abs(props.startPos.y - props.endPos.y)
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()
}
......
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