Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
DG22
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
DG22
Commits
ae15e497
Commit
ae15e497
authored
Nov 27, 2023
by
杨一航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 逻辑调整
parent
456a889d
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1844 additions
and
1117 deletions
+1844
-1117
DG22.fire
assets/DG22/scene/DG22.fire
+1533
-833
DG22.ts
assets/DG22/scene/DG22.ts
+154
-5
defaultData_DG22.ts
assets/DG22/script/defaultData_DG22.ts
+82
-279
dragObj.ts
assets/DG22/script/items/dragObj.ts
+66
-0
dragObj.ts.meta
assets/DG22/script/items/dragObj.ts.meta
+9
-0
No files found.
assets/DG22/scene/DG22.fire
View file @
ae15e497
This diff is collapsed.
Click to expand it.
assets/DG22/scene/DG22.ts
View file @
ae15e497
import
{
asyncDelay
,
onHomeworkFinish
}
from
"
../script/util_DG22
"
;
import
{
asyncDelay
,
asyncPlayDragonBoneAnimation
,
getSpriteFrimeByUrl
,
goNextPage
,
onHomeworkFinish
}
from
"
../script/util_DG22
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent_DG22
"
;
import
Boy
from
"
../script/items/boy_DG22
"
;
import
DragObj
from
"
../script/items/dragObj
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
SceneComponent
extends
MyCocosSceneComponent
{
@
property
(
cc
.
Node
)
boyNode
=
null
;
@
property
(
cc
.
Node
)
fogeNode
=
null
;
@
property
(
cc
.
Node
)
dragObj
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
itemBg
=
null
;
@
property
(
cc
.
Node
)
rect
=
null
;
@
property
(
cc
.
Node
)
box
=
null
;
@
property
(
cc
.
Node
)
dragRoot
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
btn_start
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
btn_end
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
cover
:
cc
.
Node
=
null
;
bgItemData
:
any
;
dragData
:
any
;
_rightIndex
:
number
=
0
;
_totalIndex
:
any
;
addPreloadImage
()
{
// TODO 根据自己的配置预加载图片资源
this
.
_imageResList
.
push
({
url
:
this
.
data
.
pic_url
});
this
.
_imageResList
.
push
({
url
:
this
.
data
.
pic_url_2
});
//
//
TODO 根据自己的配置预加载图片资源
//
this._imageResList.push({ url: this.data.pic_url });
//
this._imageResList.push({ url: this.data.pic_url_2 });
}
addPreloadAudio
()
{
// TODO 根据自己的配置预加载音频资源
this
.
_audioResList
.
push
({
url
:
this
.
data
.
audio_url
});
this
.
_audioResList
.
push
({
url
:
this
.
data
.
startAudio
});
this
.
_audioResList
.
push
({
url
:
this
.
data
.
endAudio
});
}
addPreloadAnima
()
{
...
...
@@ -31,22 +68,134 @@ export default class SceneComponent extends MyCocosSceneComponent {
_cantouch
=
null
;
initData
()
{
// 所有全局变量 默认都是null
cc
.
log
(
JSON
.
stringify
(
this
.
data
,
null
,
2
))
this
.
_cantouch
=
true
;
}
initView
()
{
this
.
initBg
();
this
.
initPageData
();
this
.
boyNode
.
x
=
500
;
this
.
boyNode
.
getComponent
(
Boy
).
playRun
(
-
1
);
cc
.
tween
(
this
.
boyNode
).
to
(
1
,
{
x
:
67
}).
call
(()
=>
{
this
.
boyNode
.
getComponent
(
Boy
).
playtalk
(
-
1
);
this
.
playAudioByUrl
(
this
.
data
.
startAudio
,
()
=>
{
this
.
boyNode
.
getComponent
(
Boy
).
playNormal
();
this
.
btn_start
.
active
=
true
;
})
}).
start
();
let
list
=
this
.
dragRoot
.
children
;
for
(
let
i
=
0
;
i
<
list
.
length
;
++
i
)
{
list
[
i
].
active
=
false
;
}
}
startPage
()
{
this
.
btn_start
.
active
=
false
;
this
.
cover
.
active
=
false
;
this
.
boyNode
.
getComponent
(
Boy
).
playRun
(
-
1
);
this
.
boyNode
.
scaleX
=
-
0.5
;
cc
.
tween
(
this
.
boyNode
).
to
(
1
,
{
x
:
500
}).
call
(()
=>
{
}).
start
();
this
.
initPageView
();
}
initBg
()
{
const
bgNode
=
cc
.
find
(
'
Canvas/bg
'
);
bgNode
.
scale
=
this
.
_mapScaleMax
;
cc
.
tween
(
this
.
btn_start
).
to
(
0.3
,
{
scale
:
1.1
}).
to
(
0.2
,
{
scale
:
1
}).
delay
(
1
).
union
().
repeatForever
().
start
();
this
.
cover
.
active
=
true
;
this
.
btn_start
.
on
(
"
click
"
,
this
.
startPage
,
this
)
this
.
btn_start
.
active
=
false
;
this
.
btn_end
.
active
=
false
;
this
.
btn_end
.
on
(
"
click
"
,
()
=>
{
goNextPage
();
},
this
)
}
initPageData
()
{
this
.
_rightIndex
=
0
;
this
.
bgItemData
=
this
.
data
.
questions
[
0
].
bgItem
;
this
.
dragData
=
this
.
data
.
questions
[
0
].
hotZoneItemArr
;
this
.
_totalIndex
=
this
.
dragData
.
length
;
}
initPageView
()
{
this
.
btn_end
.
getChildByName
(
"
lb
"
).
getComponent
(
cc
.
Label
).
string
=
this
.
data
.
endtxt
||
""
if
(
this
.
bgItemData
.
url
)
{
getSpriteFrimeByUrl
(
this
.
bgItemData
.
url
,
(
spf
)
=>
{
this
.
itemBg
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
spf
;
this
.
itemBg
.
width
=
this
.
bgItemData
.
rect
.
width
;
this
.
itemBg
.
height
=
this
.
bgItemData
.
rect
.
height
;
this
.
rect
.
getComponent
(
cc
.
Widget
).
updateAlignment
();
this
.
itemBg
.
scale
=
Math
.
min
(
680
/
this
.
itemBg
.
width
,
400
/
this
.
itemBg
.
height
)
})
}
let
list
=
this
.
dragRoot
.
children
;
for
(
let
i
=
0
;
i
<
this
.
dragData
.
length
;
++
i
)
{
let
itemInfo
=
this
.
dragData
[
i
];
let
item
=
cc
.
instantiate
(
this
.
box
);
item
.
parent
=
this
.
rect
;
item
.
width
=
itemInfo
.
rect
.
width
;
item
.
height
=
itemInfo
.
rect
.
height
;
item
.
x
=
itemInfo
.
rect
.
x
+
itemInfo
.
rect
.
width
/
2
;
item
.
y
=
-
itemInfo
.
rect
.
y
-
itemInfo
.
rect
.
height
/
2
;
item
.
getChildByName
(
"
lb
"
).
getComponent
(
cc
.
Label
).
string
=
itemInfo
.
text
;
item
.
getChildByName
(
"
lb
"
).
active
=
false
;
item
.
getChildByName
(
"
lb
"
).
scale
=
itemInfo
.
fontScale
;
cc
.
log
(
"
item scale ==
"
+
item
.
scale
)
list
[
i
].
scale
=
0
;
list
[
i
].
active
=
true
;
cc
.
tween
(
list
[
i
]).
to
(
0.3
,
{
scale
:
1
}).
start
();
let
dragNode
=
cc
.
instantiate
(
this
.
dragObj
);
dragNode
.
x
=
0
;
dragNode
.
y
=
0
;
dragNode
.
parent
=
list
[
i
];
dragNode
.
getChildByName
(
"
lb
"
).
getComponent
(
cc
.
Label
).
string
=
itemInfo
.
text
;
dragNode
.
getComponent
(
DragObj
).
setMatchNode
(
item
,
()
=>
{
this
.
_rightIndex
++
;
if
(
this
.
_rightIndex
==
this
.
_totalIndex
)
{
this
.
toEnd
()
}
});
dragNode
.
getComponent
(
DragObj
).
mainCom
=
this
;
}
}
async
toEnd
()
{
await
asyncPlayDragonBoneAnimation
(
this
.
fogeNode
,
"
finish
"
,
1
);
this
.
boyNode
.
scaleX
=
0.5
;
this
.
fogeNode
.
active
=
false
;
this
.
boyNode
.
getComponent
(
Boy
).
playRun
(
-
1
);
cc
.
tween
(
this
.
boyNode
).
to
(
1
,
{
x
:
67
}).
call
(()
=>
{
this
.
boyNode
.
getComponent
(
Boy
).
playtalk
(
-
1
);
this
.
playAudioByUrl
(
this
.
data
.
endAudio
,
()
=>
{
this
.
boyNode
.
getComponent
(
Boy
).
playNormal
();
this
.
btn_end
.
active
=
true
;
})
}).
start
()
}
initListener
()
{
}
...
...
assets/DG22/script/defaultData_DG22.ts
View file @
ae15e497
This diff is collapsed.
Click to expand it.
assets/DG22/script/items/dragObj.ts
0 → 100644
View file @
ae15e497
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
DragObj
extends
cc
.
Component
{
_touchStart
:
boolean
;
_originPos
:
any
;
_matched
:
boolean
;
_matcheNode
:
cc
.
Node
;
mainCom
:
any
;
_sucCall
:
Function
;
onLoad
()
{
this
.
_originPos
=
this
.
node
.
position
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
)
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
this
.
onTouchMove
,
this
)
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
)
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
this
.
onTouchEnd
,
this
)
}
onTouchStart
()
{
this
.
_touchStart
=
true
;
}
onTouchMove
(
touch
:
cc
.
Touch
)
{
if
(
this
.
_touchStart
)
{
let
delta
=
touch
.
getDelta
();
this
.
node
.
x
+=
delta
.
x
;
this
.
node
.
y
+=
delta
.
y
;
if
(
this
.
node
.
getBoundingBoxToWorld
().
intersects
(
this
.
_matcheNode
.
getBoundingBoxToWorld
()))
{
cc
.
log
(
"
------contersects-----
"
);
this
.
_matched
=
true
;
}
else
{
this
.
_matched
=
false
;
}
}
}
onTouchEnd
()
{
this
.
_touchStart
=
false
;
if
(
!
this
.
_matched
)
{
this
.
mainCom
.
playLocalAudio
(
"
btn
"
);
cc
.
tween
(
this
.
node
).
to
(
0.3
,
{
x
:
this
.
_originPos
.
x
,
y
:
this
.
_originPos
.
y
}).
start
();
}
else
{
this
.
mainCom
.
playLocalAudio
(
"
right
"
);
this
.
node
.
active
=
false
;
this
.
_matcheNode
.
getChildByName
(
"
lb
"
).
active
=
true
;
cc
.
tween
(
this
.
node
.
parent
).
to
(
0.5
,
{
scale
:
0
},
{
easing
:
"
sineOut
"
}).
start
();
this
.
_sucCall
&&
this
.
_sucCall
();
// this.node.parent.active = false;
}
}
setMatchNode
(
node
:
cc
.
Node
,
sucCall
:
Function
)
{
this
.
_matcheNode
=
node
;
this
.
_sucCall
=
sucCall
;
}
}
assets/DG22/script/items/dragObj.ts.meta
0 → 100644
View file @
ae15e497
{
"ver": "1.0.8",
"uuid": "94f0f48d-879e-491d-a493-4d34e1254b72",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
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