Commit 3773d5c3 authored by Master Q's avatar Master Q

简单搭建

parent 4fb8eb2f
This diff is collapsed.
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
"keys": "bucket_GE.png,countDown.svga,mountain.svga,normalGamer.svga,powerBall.svga,scene-back.jpg,speedShow.svga,speedUpGamer.svga,tree.svga", "keys": "bucket_GE.png,countDown.svga,mountain.svga,normalGamer.svga,powerBall.svga,scene-back.jpg,speedShow.svga,speedUpGamer.svga,tree.svga",
"name": "GameRes" "name": "GameRes"
}, },
{
"keys": "back.png,fkingCar.png,obstack1.png,obstack2.png,obstack3.png,背景移动元素.svga,跑道.svga,路架子.svga",
"name": "GameScene"
},
{ {
"keys": "comCloseBtn.png,com_bg.jpg,toastBg.png,waitingBg.png,waitingRot.png", "keys": "comCloseBtn.png,com_bg.jpg,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common" "name": "common"
......
...@@ -4,6 +4,10 @@ export const ResJson = { ...@@ -4,6 +4,10 @@ export const ResJson = {
"keys": "bucket_GE.png,countDown.svga,mountain.svga,normalGamer.svga,powerBall.svga,scene-back.jpg,speedShow.svga,speedUpGamer.svga,tree.svga", "keys": "bucket_GE.png,countDown.svga,mountain.svga,normalGamer.svga,powerBall.svga,scene-back.jpg,speedShow.svga,speedUpGamer.svga,tree.svga",
"name": "GameRes" "name": "GameRes"
}, },
{
"keys": "back.png,fkingCar.png,obstack1.png,obstack2.png,obstack3.png,背景移动元素.svga,跑道.svga,路架子.svga",
"name": "GameScene"
},
{ {
"keys": "comCloseBtn.png,com_bg.jpg,toastBg.png,waitingBg.png,waitingRot.png", "keys": "comCloseBtn.png,com_bg.jpg,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common" "name": "common"
......
...@@ -73,40 +73,40 @@ export const ParkourGameEvents = { ...@@ -73,40 +73,40 @@ export const ParkourGameEvents = {
/** /**
* 跑酷游戏的简单配置项 * 跑酷游戏的简单配置项
* 注意 png 或者 jpg的 不用设置 anchorX 和 anchorY
*/ */
export const ParkourGameConfig: ParkourGameConfigInfer = { export const ParkourGameConfig: ParkourGameConfigInfer = {
ParkourGamer: { ParkourGamer: {
Container: 'normalGamer.svga', Container: class extends FYGE.Container {
// class extends FYGE.Container { constructor() {
// constructor() { super();
// super();
// this.onInitUi() this.onInitUi()
// } }
// onInitUi() { onInitUi() {
// UI.MoiveClip(this, 'normalGamer.svga') UI.Sp(this, 'fkingCar.png')
// } }
// }, },
collisionConfig: { collisionConfig: {
type: 'rect', type: 'rect',
x: 60, x: 0,
y: 300, y: 0,
w: 220, w: 140,
h: 60 h: 180
}, },
anchorX: 165, anchorX: 70,
anchorY: 135 anchorY: 35
}, },
ConveyorBeltList: [ ConveyorBeltList: [
{ {
startPos: { startPos: {
x: 358, x: 374,
y: 510, y: 200,
}, },
endPos: { endPos: {
x: -308, x: 0,
y: 1624 y: 1624
}, },
startTyl: 400, startTyl: 400,
...@@ -114,22 +114,24 @@ export const ParkourGameConfig: ParkourGameConfigInfer = { ...@@ -114,22 +114,24 @@ export const ParkourGameConfig: ParkourGameConfigInfer = {
}, },
{ {
startPos: { startPos: {
x: 380, x: 378,
y: 510, y: 200,
}, },
endPos: { endPos: {
x: 355, y: 1624 x: 378,
y: 1624
}, },
startTyl: 400, startTyl: 400,
scaleEndProportion: 0.8 scaleEndProportion: 0.8
}, },
{ {
startPos: { startPos: {
x: 402, x: 384,
y: 510, y: 200,
}, },
endPos: { endPos: {
x: 1050, y: 1624 x: 750,
y: 1624
}, },
startTyl: 300, startTyl: 300,
scaleEndProportion: 0.8 scaleEndProportion: 0.8
...@@ -138,52 +140,50 @@ export const ParkourGameConfig: ParkourGameConfigInfer = { ...@@ -138,52 +140,50 @@ export const ParkourGameConfig: ParkourGameConfigInfer = {
ParkourGameEleList: [ ParkourGameEleList: [
{ {
uniqueKey: 'uniqueKey1', uniqueKey: 'uniqueKey1',
Container: 'bucket_GE.png', Container: 'obstack1.png',
ProbabilityPort: 10, ProbabilityPort: 10,
collisionConfig: { collisionConfig: {
type: 'rect', type: 'rect',
x: -100, x: -50,
y: 30, y: 0,
w: 200, w: 100,
h: 50 h: 50
} }
}, },
{ {
uniqueKey: 'uniqueKey2', uniqueKey: 'uniqueKey2',
Container: 'powerBall.svga', Container: 'obstack2.png',
ProbabilityPort: 10, ProbabilityPort: 10,
anchorX: 130, // anchorX: 130,
anchorY: 130, // anchorY: 130,
collisionConfig: { collisionConfig: {
type: 'rect', type: 'rect',
x: 40, x: -50,
y: 140, y: 0,
w: 200, w: 100,
h: 60 h: 50
} }
}, },
{ {
uniqueKey: 'uniqueKey3', uniqueKey: 'uniqueKey3',
Container: class extends FYGE.Container { Container: 'obstack3.png',
constructor() { ProbabilityPort: 10,
super(); // anchorX: 100,
this.onInitUi() // anchorY: 100,
} collisionConfig: {
type: 'rect',
onInitUi() { x: -50,
UI.Rect(this, 200, 200, 0x000000, 20) y: 0,
w: 100,
h: 50
} }
},
ProbabilityPort: 8,
anchorX: 100,
anchorY: 100
} }
], ],
CommonConfig: { CommonConfig: {
speed: 300, speed: 300,
CollisionDebug: true, CollisionDebug: false,
GamerAxisY: 1100, GamerAxisY: 1100,
GamerIndex: 1, GamerIndex: 1,
DetermineXAxis: 100 DetermineXAxis: 50
} }
} }
\ No newline at end of file
...@@ -12,8 +12,13 @@ function SolveUnivariateEquation(x1: number, y1: number, x2: number, y2: number) ...@@ -12,8 +12,13 @@ function SolveUnivariateEquation(x1: number, y1: number, x2: number, y2: number)
} }
export class ParkourScene extends Scene { export class ParkourScene extends Scene {
get groupNames(): string[] {
return ['GameScene']
}
conBeltList: ConveyorBelt[] = [] conBeltList: ConveyorBelt[] = []
NewContIns: ConveyorBeltItem NewContIns: ConveyorBeltItem
MovieClipList: FYGE.MovieClip[] = []
_GamerIndex: number _GamerIndex: number
...@@ -31,16 +36,18 @@ export class ParkourScene extends Scene { ...@@ -31,16 +36,18 @@ export class ParkourScene extends Scene {
this._GamerIndex = v this._GamerIndex = v
const y = ParkourGameConfig.CommonConfig.GamerAxisY const y = ParkourGameConfig.CommonConfig.GamerAxisY
const x = (y - b) / k const x = !Number.isFinite(k) ? data.startPos.x : (y - b) / k
this.NewContIns.setPosition(x, y) this.NewContIns.setPosition(x, y)
} }
} }
initUi() { initUi() {
UI.Sp(this, 'scene-back.jpg') const BaseScene = UI.Ctn(this)
UI.Sp(BaseScene, 'back.png')
this.MovieClipList.push(UI.MoiveClip(BaseScene, '跑道.svga'))
// this.MovieClipList.push(UI.MoiveClip(BaseScene, '背景移动元素.svga'))
// this.MovieClipList.push(UI.MoiveClip(BaseScene, '路架子.svga'))
ParkourGameConfig.ConveyorBeltList.forEach((item, index) => { ParkourGameConfig.ConveyorBeltList.forEach((item, index) => {
this.conBeltList.push(this.addChild(new ConveyorBelt({ this.conBeltList.push(this.addChild(new ConveyorBelt({
......
...@@ -132,6 +132,16 @@ export class ConveyorBelt extends FYGE.Container { ...@@ -132,6 +132,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