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

简单搭建

parent 4fb8eb2f
This diff is collapsed.
......@@ -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",
"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",
"name": "common"
......
......@@ -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",
"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",
"name": "common"
......
......@@ -73,40 +73,40 @@ export const ParkourGameEvents = {
/**
* 跑酷游戏的简单配置项
* 注意 png 或者 jpg的 不用设置 anchorX 和 anchorY
*/
export const ParkourGameConfig: ParkourGameConfigInfer = {
ParkourGamer: {
Container: 'normalGamer.svga',
// class extends FYGE.Container {
// constructor() {
// super();
Container: class extends FYGE.Container {
constructor() {
super();
// this.onInitUi()
// }
this.onInitUi()
}
// onInitUi() {
// UI.MoiveClip(this, 'normalGamer.svga')
// }
// },
onInitUi() {
UI.Sp(this, 'fkingCar.png')
}
},
collisionConfig: {
type: 'rect',
x: 60,
y: 300,
w: 220,
h: 60
x: 0,
y: 0,
w: 140,
h: 180
},
anchorX: 165,
anchorY: 135
anchorX: 70,
anchorY: 35
},
ConveyorBeltList: [
{
startPos: {
x: 358,
y: 510,
x: 374,
y: 200,
},
endPos: {
x: -308,
x: 0,
y: 1624
},
startTyl: 400,
......@@ -114,22 +114,24 @@ export const ParkourGameConfig: ParkourGameConfigInfer = {
},
{
startPos: {
x: 380,
y: 510,
x: 378,
y: 200,
},
endPos: {
x: 355, y: 1624
x: 378,
y: 1624
},
startTyl: 400,
scaleEndProportion: 0.8
},
{
startPos: {
x: 402,
y: 510,
x: 384,
y: 200,
},
endPos: {
x: 1050, y: 1624
x: 750,
y: 1624
},
startTyl: 300,
scaleEndProportion: 0.8
......@@ -138,52 +140,50 @@ export const ParkourGameConfig: ParkourGameConfigInfer = {
ParkourGameEleList: [
{
uniqueKey: 'uniqueKey1',
Container: 'bucket_GE.png',
Container: 'obstack1.png',
ProbabilityPort: 10,
collisionConfig: {
type: 'rect',
x: -100,
y: 30,
w: 200,
x: -50,
y: 0,
w: 100,
h: 50
}
},
{
uniqueKey: 'uniqueKey2',
Container: 'powerBall.svga',
Container: 'obstack2.png',
ProbabilityPort: 10,
anchorX: 130,
anchorY: 130,
// anchorX: 130,
// anchorY: 130,
collisionConfig: {
type: 'rect',
x: 40,
y: 140,
w: 200,
h: 60
x: -50,
y: 0,
w: 100,
h: 50
}
},
{
uniqueKey: 'uniqueKey3',
Container: class extends FYGE.Container {
constructor() {
super();
this.onInitUi()
}
onInitUi() {
UI.Rect(this, 200, 200, 0x000000, 20)
}
},
ProbabilityPort: 8,
anchorX: 100,
anchorY: 100
Container: 'obstack3.png',
ProbabilityPort: 10,
// anchorX: 100,
// anchorY: 100,
collisionConfig: {
type: 'rect',
x: -50,
y: 0,
w: 100,
h: 50
}
}
],
CommonConfig: {
speed: 300,
CollisionDebug: true,
CollisionDebug: false,
GamerAxisY: 1100,
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)
}
export class ParkourScene extends Scene {
get groupNames(): string[] {
return ['GameScene']
}
conBeltList: ConveyorBelt[] = []
NewContIns: ConveyorBeltItem
MovieClipList: FYGE.MovieClip[] = []
_GamerIndex: number
......@@ -31,16 +36,18 @@ export class ParkourScene extends Scene {
this._GamerIndex = v
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)
}
}
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) => {
this.conBeltList.push(this.addChild(new ConveyorBelt({
......
......@@ -132,6 +132,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