Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DuibaGameTemplate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
钱根
DuibaGameTemplate
Commits
2added8b
Commit
2added8b
authored
Jun 16, 2022
by
Master Q
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
简单的做一个 tween 动画
parent
4fb8eb2f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
5 deletions
+54
-5
ParkourGameScene.ts
src/scenes/ParkourGameScene.ts
+24
-1
ConveyorBelt.ts
src/scenes/comp/ConveyorBelt.ts
+30
-4
No files found.
src/scenes/ParkourGameScene.ts
View file @
2added8b
...
@@ -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
,
...
...
src/scenes/comp/ConveyorBelt.ts
View file @
2added8b
...
@@ -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
()
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment