Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
new_taobao
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
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
wildfirecode13
new_taobao
Commits
55068487
Commit
55068487
authored
Sep 27, 2020
by
AU-Pro-mac
Browse files
Options
Browse Files
Download
Plain Diff
fix conflect
parents
904eaecc
229b0962
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
615 additions
and
113 deletions
+615
-113
copyJs.js
project/src/canvas/game/scripts/copyJs.js
+16
-16
StartScene.ts
project/src/canvas/game/src/scenes/StartScene.ts
+0
-1
CircleItem.ts
project/src/canvas/game/src/xiaoxiaole/CircleItem.ts
+61
-0
MainScene.ts
project/src/canvas/game/src/xiaoxiaole/MainScene.ts
+0
-89
ObjectPool.ts
project/src/canvas/game/src/xiaoxiaole/ObjectPool.ts
+28
-0
XxlScene.ts
project/src/canvas/game/src/xiaoxiaole/XxlScene.ts
+510
-7
No files found.
project/src/canvas/game/scripts/copyJs.js
View file @
55068487
project/src/canvas/game/src/scenes/StartScene.ts
View file @
55068487
...
...
@@ -3,7 +3,6 @@ import { RES } from "../../module/RES";
import
Root
from
"./Root"
;
// import res from "../../test/output.json"
import
resCanvasList
from
"../../../game/resCanvasList"
import
{
MainScene
}
from
"../xiaoxiaole/MainScene"
;
import
{
Ins
}
from
"../Ins"
;
import
{
changeScene
,
showPanel
}
from
"../../module/ctrls"
;
import
{
SelectCatPanel
}
from
"../panels/selectcatpanel/SelectCatPanel"
;
...
...
project/src/canvas/game/src/xiaoxiaole/CircleItem.ts
0 → 100644
View file @
55068487
import
{
RES
}
from
"../../module/RES"
;
import
resCanvasList
from
"../../resCanvasList"
;
declare
interface
point
{
x
:
number
;
y
:
number
;
}
export
default
class
CircleItem
extends
FYGE
.
Sprite
{
//类型
type
:
number
circleRes
=
[
'2a747211-0210-4215-86a2-a6955b37c45b'
,
'7d1ec658-9371-4d52-b4d7-e75d04037daf'
,
'6a1345f6-969c-4969-8bfb-f4de637df34d'
,
'2e12a9ec-46be-487f-a9cd-550dd0af3746'
]
point
:
point
index
:
number
nnnn
:
number
constructor
(
type
:
number
,
point
:
point
,
index
:
number
)
{
super
();
this
.
type
=
type
this
.
point
=
{
x
:
point
.
x
+
39
,
y
:
point
.
y
+
39
}
this
.
x
=
point
.
x
this
.
y
=
point
.
y
this
.
index
=
index
this
.
texture
=
RES
.
getRes
(
resCanvasList
[
this
.
circleRes
[
type
]].
url
);
}
toBig
()
{
console
.
log
(
"变大"
)
this
.
scaleX
=
1.1
this
.
scaleY
=
1.1
}
toNormal
()
{
this
.
scaleY
=
this
.
scaleX
=
1
}
changeConfig
(
type
:
number
,
point
:
point
,
index
:
number
)
{
this
.
type
=
type
this
.
point
=
{
x
:
point
.
x
+
39
,
y
:
point
.
y
+
39
}
this
.
x
=
point
.
x
this
.
y
=
point
.
y
this
.
index
=
index
this
.
texture
=
RES
.
getRes
(
resCanvasList
[
this
.
circleRes
[
type
]].
url
);
}
}
project/src/canvas/game/src/xiaoxiaole/MainScene.ts
deleted
100644 → 0
View file @
904eaecc
import
{
Scene
}
from
"../../module/views/Scene"
;
import
resCanvasList
from
"../../resCanvasList"
;
import
{
RES
}
from
"../../module/RES"
;
import
{
Ins
}
from
"../Ins"
;
import
{
MainSceneBtnUi
}
from
"../ui/mainSceneBtnUi"
;
import
{
MSG
,
SCENETYPE
}
from
"../Enum"
;
import
{
showToast
}
from
"../../module/ctrls"
;
import
{
GDispatcher
}
from
"../Main"
;
import
{
Cat
}
from
"../cat/Cat"
;
import
{
Tools
}
from
"../Tools"
;
export
class
MainScene
extends
Scene
{
bg
:
FYGE
.
Sprite
initUi
()
{
var
that
=
this
;
that
.
initSceneEle
();
this
.
bg
=
Ins
.
initSprite
(
"7fcd3fb3-57bd-436a-afca-989b68b6b311"
)
this
.
addChild
(
this
.
bg
);
this
.
x
=
(
Ins
.
stageW
-
750
)
>>
1
;
this
.
y
=
(
Ins
.
stageH
-
1624
)
>>
1
;
this
.
setHexagram
(
7
)
}
// 初始化六角形4/7/10/13/16....
setHexagram
(
max
:
number
)
{
let
c
=
Math
.
ceil
(
max
/
2
)
let
x
=
(
2
*
max
+
1
)
/
3
let
str
=
""
for
(
let
i
=
0
;
i
<
2
*
max
-
x
;
i
++
)
{
if
(
i
<
max
-
x
)
{
for
(
let
j
=
0
;
j
<=
i
;
j
++
)
{
str
+=
`
${
j
}
`
}
str
+=
'
\
n'
}
else
if
(
i
>=
max
-
x
&&
i
<=
c
)
{
console
.
log
(
i
,
max
-
i
-
2
+
x
)
for
(
let
j
=
max
-
i
-
2
+
x
;
j
>
0
;
j
--
)
{
str
+=
`
${
j
}
`
}
str
+=
'
\
n'
}
else
if
(
i
>
c
&&
i
<
max
)
{
for
(
let
j
=
0
;
j
<
i
+
1
;
j
++
)
{
str
+=
`
${
j
}
`
}
str
+=
'
\
n'
}
else
{
for
(
let
j
=
max
-
i
-
2
+
x
;
j
>
0
;
j
--
)
{
str
+=
`
${
j
}
`
}
str
+=
'
\
n'
}
}
console
.
log
(
str
)
}
/**初始化场景元素 */
initSceneEle
()
{
console
.
log
(
1111
)
}
initEvents
()
{
var
that
=
this
;
console
.
log
(
"主场景添加事件"
)
// that.tlBtn.addEventListener(FYGE.MouseEvent.CLICK,()=>{that.changeMainScene(SCENETYPE.CLASSROOM)},that);
// that.mxqBtn.addEventListener(FYGE.MouseEvent.CLICK,()=>{that.changeMainScene(SCENETYPE.PLAYGROUND)},that);
// FYGE.GDispatcher.addEventListener(MSG.CHANGE_SCENE,()=>{that.changeMainScene(SCENETYPE.BEADROOM)},that);
}
removeEvents
()
{
var
that
=
this
;
console
.
log
(
"主场景移除事件"
)
// that.tlBtn.removeEventListener(FYGE.MouseEvent.CLICK,()=>{that.changeMainScene(SCENETYPE.CLASSROOM)},that);
// that.mxqBtn.removeEventListener(FYGE.MouseEvent.CLICK,()=>{that.changeMainScene(SCENETYPE.PLAYGROUND)},that);
// FYGE.GDispatcher.removeEventListener(MSG.CHANGE_SCENE,()=>{that.changeMainScene(SCENETYPE.BEADROOM)},that);
}
}
\ No newline at end of file
project/src/canvas/game/src/xiaoxiaole/ObjectPool.ts
0 → 100644
View file @
55068487
import
CircleItem
from
"./CircleItem"
declare
interface
point
{
x
:
number
;
y
:
number
;
}
export
class
ObjectPool
{
_circleItemPool
:
CircleItem
[]
=
[]
getItem
(
type
:
number
,
ponit
:
point
,
index
:
number
):
CircleItem
{
// console.log(this._circleItemPool.length)
let
co
=
this
.
_circleItemPool
.
shift
()
if
(
co
)
{
co
.
changeConfig
(
type
,
ponit
,
index
)
}
return
co
||
new
CircleItem
(
type
,
ponit
,
index
)
}
putItem
(
co
:
CircleItem
)
{
if
(
co
.
parent
)
{
co
.
parent
.
removeChild
(
co
)
}
this
.
_circleItemPool
.
push
(
co
)
}
}
\ No newline at end of file
project/src/canvas/game/src/xiaoxiaole/XxlScene.ts
View file @
55068487
...
...
@@ -5,20 +5,523 @@ import resCanvasList from "../../resCanvasList"
import
{
Ins
}
from
"../Ins"
;
import
{
changeScene
,
showPanel
}
from
"../../module/ctrls"
;
import
{
SelectCatPanel
}
from
"../panels/selectcatpanel/SelectCatPanel"
;
import
{
MainScene
}
from
"./MainScene"
;
import
CircleItem
from
"./CircleItem"
;
import
{
ObjectPool
}
from
"./ObjectPool"
;
declare
interface
point
{
x
:
number
;
y
:
number
;
}
class
noder
{
mother
:
noder
=
null
father
:
noder
=
null
index
:
number
item
:
CircleItem
=
null
p
:
point
=
null
constructor
(
index
:
number
)
{
this
.
index
=
index
}
}
export
class
XxlScene
extends
Scene
{
bg
:
FYGE
.
Sprite
container
:
FYGE
.
Container
/**
* 右移偶数行
*/
hexIndices
=
[
[
3
],
[
9
,
10
],
[
14
,
15
,
16
,
17
,
18
,
19
,
20
],
[
21
,
22
,
23
,
24
,
25
,
26
],
[
29
,
30
,
31
,
32
,
33
],
[
35
,
36
,
37
,
38
,
39
,
40
],
[
42
,
43
,
44
,
45
,
46
,
47
,
48
],
[
51
,
52
],
[
59
]
]
/**
* 手动映射
*/
map
=
new
Map
()
/**
* 格子半径
*/
radius
=
78
;
ROW_NUM
=
9
;
COL_NUM
=
7
;
halfSq3
=
Math
.
sqrt
(
3
)
/
2
;
offsetX
=
0
;
offsetY
=
0
;
/**
* 行列位置,记录每个格子中心点的位置吧
*/
rowColPositions
=
{};
/**
* row和col转换到index的hashMap
*/
rcToIndexMap
=
{};
/**
* index到row和col的hashMap
*/
indexToRcMap
:
[
number
,
number
][]
=
[];
/**
* 索引位置
*/
indexPositions
:
point
[]
=
[];
/**
* circleItem数组
*/
circleItems
:
CircleItem
[]
=
[]
//选中的item
firstSelectItem
:
CircleItem
=
null
//选中的数组
selectItems
:
CircleItem
[]
=
[]
//空的位置
emptyHexIndices
:
number
[]
=
[]
objectPool
:
ObjectPool
//集合
ItemMap
:
Map
<
number
,
noder
>
=
new
Map
()
initUi
()
{
super
.
initUi
();
var
sceneBg
=
Ins
.
initSprite
(
"b3c8c187-e5c9-4968-9a00-a118d18ab2fc"
);
this
.
addChild
(
sceneBg
);
this
.
objectPool
=
new
ObjectPool
()
let
that
=
this
;
(
function
init
()
{
for
(
var
i
=
0
;
i
<
that
.
ROW_NUM
;
i
++
)
{
for
(
var
j
=
0
;
j
<
that
.
COL_NUM
;
j
++
)
{
that
.
rcToIndexMap
[
""
+
i
+
j
]
=
i
*
that
.
COL_NUM
+
j
;
// console.log(i * that.COL_NUM + j)
that
.
indexToRcMap
[
i
*
that
.
COL_NUM
+
j
]
=
[
i
,
j
];
var
x
=
that
.
offsetX
+
(
i
&
1
)
*
that
.
radius
/
2
+
j
*
that
.
radius
;
var
y
=
that
.
offsetY
+
i
*
that
.
halfSq3
*
that
.
radius
that
.
rowColPositions
[
""
+
i
+
j
]
=
{
x
:
x
,
y
:
y
};
that
.
indexPositions
[
i
*
that
.
COL_NUM
+
j
]
=
{
x
:
x
,
y
:
y
};
}
}
})()
that
.
initSceneEle
();
this
.
bg
=
Ins
.
initSprite
(
"7fcd3fb3-57bd-436a-afca-989b68b6b311"
)
this
.
addChild
(
this
.
bg
);
this
.
x
=
(
Ins
.
stageW
-
750
)
>>
1
;
this
.
y
=
(
Ins
.
stageH
-
1624
)
>>
1
;
// showPanel(SelectCatPanel);
// this.addChild(new MainScene());
this
.
container
=
new
FYGE
.
Container
this
.
container
.
x
=
105
this
.
container
.
y
=
655
this
.
addChild
(
this
.
container
)
let
expendHexIndices
=
[]
for
(
let
i
of
this
.
hexIndices
)
{
expendHexIndices
.
push
(...
i
)
}
//初始化
for
(
let
i
of
expendHexIndices
)
{
let
p
:
point
=
{
x
:
that
.
getPositionByIndex
(
i
).
x
,
y
:
that
.
getPositionByIndex
(
i
).
y
}
let
no
=
new
noder
(
i
)
let
circleItem
=
this
.
objectPool
.
getItem
(
Math
.
floor
(
4
*
Math
.
random
()),
p
,
i
)
no
.
item
=
circleItem
no
.
p
=
p
this
.
ItemMap
.
set
(
i
,
no
)
this
.
container
.
addChild
(
circleItem
)
this
.
circleItems
.
push
(
circleItem
)
}
for
(
let
i
=
this
.
hexIndices
.
length
-
1
;
i
>=
0
;
i
--
)
{
if
(
i
-
1
>=
0
)
{
let
l1
=
this
.
hexIndices
[
i
].
length
let
l2
=
this
.
hexIndices
[
i
-
1
].
length
let
t1
=
l1
>>
1
let
t2
=
l2
>>
1
if
(
l1
&
1
)
{
//遍历奇数行每行的父母节点
for
(
let
offset
=
0
;
offset
<=
t1
;
offset
++
)
{
if
(
offset
)
{
//右移
const
fatherrightindex
=
this
.
hexIndices
[
i
-
1
][
t2
-
1
+
offset
]
const
motherrightindex
=
this
.
hexIndices
[
i
-
1
][
t2
+
offset
]
const
nowrightindex
=
this
.
hexIndices
[
i
][
t1
+
offset
]
let
fatherright
=
this
.
ItemMap
.
get
(
fatherrightindex
)
let
motherright
=
this
.
ItemMap
.
get
(
motherrightindex
)
let
nowright
=
this
.
ItemMap
.
get
(
nowrightindex
)
nowright
.
father
=
fatherright
nowright
.
mother
=
motherright
//左移
let
fatherleftindex
=
this
.
hexIndices
[
i
-
1
][
t2
-
1
-
offset
]
let
motherleftindex
=
this
.
hexIndices
[
i
-
1
][
t2
-
offset
]
let
nowleftindex
=
this
.
hexIndices
[
i
][
t1
-
offset
]
let
nowleft
=
this
.
ItemMap
.
get
(
nowleftindex
)
let
fatherleft
=
this
.
ItemMap
.
get
(
fatherleftindex
)
let
motherleft
=
this
.
ItemMap
.
get
(
motherleftindex
)
nowleft
.
father
=
fatherleft
nowleft
.
mother
=
motherleft
}
else
{
//中间项
let
fatherindex
=
this
.
hexIndices
[
i
-
1
][
t2
-
1
]
let
motherindex
=
this
.
hexIndices
[
i
-
1
][
t2
]
let
nowindex
=
this
.
hexIndices
[
i
][
t1
]
let
now
=
this
.
ItemMap
.
get
(
nowindex
)
now
.
father
=
this
.
ItemMap
.
get
(
fatherindex
)
now
.
mother
=
this
.
ItemMap
.
get
(
motherindex
)
}
}
}
else
{
//遍历偶数行每行的父母节点
for
(
let
offset
=
0
;
offset
<
t1
;
offset
++
)
{
//右移
let
fatherrightindex
=
this
.
hexIndices
[
i
-
1
][
t2
-
1
+
offset
]
let
motherrightindex
=
this
.
hexIndices
[
i
-
1
][
t2
+
offset
]
let
nowrightindex
=
this
.
hexIndices
[
i
][
t1
+
offset
]
let
nowright
=
this
.
ItemMap
.
get
(
nowrightindex
)
nowright
.
father
=
this
.
ItemMap
.
get
(
fatherrightindex
)
nowright
.
mother
=
this
.
ItemMap
.
get
(
motherrightindex
)
//左移
let
fatherleftindex
=
this
.
hexIndices
[
i
-
1
][
t2
-
1
-
offset
]
let
motherleftindex
=
this
.
hexIndices
[
i
-
1
][
t2
-
offset
]
let
nowleftindex
=
this
.
hexIndices
[
i
][
t1
-
offset
-
1
]
let
nowleft
=
this
.
ItemMap
.
get
(
nowleftindex
)
nowleft
.
father
=
this
.
ItemMap
.
get
(
fatherleftindex
)
nowleft
.
mother
=
this
.
ItemMap
.
get
(
motherleftindex
)
}
}
}
}
console
.
log
(
this
.
ItemMap
)
}
g
:
FYGE
.
Graphics
mouseDown
(
e
)
{
let
p
:
point
=
{
x
:
e
.
localX
-
this
.
container
.
x
,
y
:
e
.
localY
-
this
.
container
.
y
}
let
co
=
this
.
findFirstCircleItemByPos
(
p
)
if
(
co
)
{
//划线
this
.
g
=
new
FYGE
.
Graphics
()
this
.
container
.
addChild
(
this
.
g
)
this
.
g
.
moveTo
(
co
.
point
.
x
,
co
.
point
.
y
);
this
.
g
.
beginFill
(
"#ffffff"
)
this
.
g
.
lineStyle
(
2
,
0x000000
)
co
.
toBig
()
this
.
firstSelectItem
=
co
this
.
selectItems
.
push
(
co
)
this
.
addEventListener
(
FYGE
.
MouseEvent
.
MOUSE_MOVE
,
this
.
mouseMove
,
this
);
}
}
mouseMove
(
e
)
{
let
p
:
point
=
{
x
:
e
.
localX
-
this
.
container
.
x
,
y
:
e
.
localY
-
this
.
container
.
y
}
let
co
=
this
.
firstSelectItem
if
(
this
.
selectItems
.
length
>
0
)
{
co
=
this
.
findCircleItemByPos
(
this
.
selectItems
[
this
.
selectItems
.
length
-
1
].
point
,
p
)
}
if
(
this
.
firstSelectItem
)
{
if
(
co
&&
co
.
type
==
this
.
firstSelectItem
.
type
)
{
// console.log(co.point, co.type)
co
.
toBig
()
this
.
selectItems
.
push
(
co
)
//连线
this
.
g
.
lineTo
(
co
.
point
.
x
,
co
.
point
.
y
)
this
.
g
.
endFill
()
this
.
g
.
moveTo
(
co
.
point
.
x
,
co
.
point
.
y
)
}
}
else
{
if
(
co
)
{
//画线
this
.
g
=
new
FYGE
.
Graphics
()
this
.
container
.
addChild
(
this
.
g
)
this
.
g
.
moveTo
(
co
.
point
.
x
,
co
.
point
.
y
);
this
.
g
.
beginFill
(
"#ffffff"
)
this
.
g
.
lineStyle
(
2
,
0x000000
)
co
.
toBig
()
this
.
firstSelectItem
=
co
this
.
selectItems
.
push
(
co
)
}
}
}
mouseUp
(
e
)
{
this
.
g
.
clear
()
this
.
removeEventListener
(
FYGE
.
MouseEvent
.
MOUSE_MOVE
,
this
.
mouseMove
,
this
);
let
p
:
point
=
{
x
:
e
.
localX
,
y
:
e
.
localY
}
if
(
this
.
selectItems
.
length
>
1
)
{
for
(
let
co
of
this
.
selectItems
)
{
co
.
toNormal
()
if
(
co
.
parent
)
{
this
.
ItemMap
.
get
(
co
.
index
).
item
=
null
this
.
emptyHexIndices
.
push
(
co
.
index
)
this
.
circleItems
=
this
.
circleItems
.
filter
(
item
=>
item
!=
co
)
this
.
objectPool
.
putItem
(
co
)
}
else
{
console
.
log
(
"不存在"
,
co
.
nnnn
)
}
}
}
else
{
for
(
let
co
of
this
.
selectItems
)
{
co
.
toNormal
()
}
}
this
.
firstSelectItem
=
null
this
.
selectItems
.
splice
(
0
)
if
(
this
.
emptyHexIndices
.
length
>
0
)
{
//掉落
this
.
drop
()
}
}
drop
()
{
this
.
emptyHexIndices
=
Array
.
from
(
new
Set
(
this
.
emptyHexIndices
));
this
.
emptyHexIndices
.
sort
((
a
,
b
)
=>
b
-
a
)
// console.log("掉落", this.emptyHexIndices)
let
index
=
this
.
emptyHexIndices
[
0
]
if
(
index
)
{
let
p
:
point
=
{
x
:
this
.
getPositionByIndex
(
index
).
x
,
y
:
this
.
getPositionByIndex
(
index
).
y
}
let
vo
=
this
.
ItemMap
.
get
(
index
)
if
(
vo
)
{
this
.
findFatherOrMother
(
vo
)
}
}
else
{
debugger
}
}
findFatherOrMother
(
vo
:
noder
)
{
let
fa
=
vo
.
father
if
(
fa
&&
fa
.
item
)
{
this
.
emptyHexIndices
.
push
(
fa
.
index
)
this
.
emptyHexIndices
.
splice
(
this
.
emptyHexIndices
.
indexOf
(
vo
.
index
),
1
)
vo
.
item
=
fa
.
item
fa
.
item
=
null
vo
.
item
.
index
=
vo
.
index
this
.
exchange
(
vo
.
item
,
{
x
:
this
.
getPositionByIndex
(
vo
.
index
).
x
,
y
:
this
.
getPositionByIndex
(
vo
.
index
).
y
})
}
else
{
let
mo
=
vo
.
mother
if
(
mo
&&
mo
.
item
)
{
this
.
emptyHexIndices
.
push
(
mo
.
index
)
this
.
emptyHexIndices
.
splice
(
this
.
emptyHexIndices
.
indexOf
(
vo
.
index
),
1
)
vo
.
item
=
mo
.
item
mo
.
item
=
null
vo
.
item
.
index
=
vo
.
index
this
.
exchange
(
vo
.
item
,
{
x
:
this
.
getPositionByIndex
(
vo
.
index
).
x
,
y
:
this
.
getPositionByIndex
(
vo
.
index
).
y
})
}
else
{
let
lastVo
=
(
fa
&&
fa
.
father
)
?
fa
:
null
||
(
mo
&&
mo
.
father
)
?
mo
:
null
||
(
fa
&&
fa
.
mother
)
?
fa
:
null
||
(
mo
&&
mo
.
mother
)
?
mo
:
null
if
(
lastVo
)
{
this
.
findFatherOrMother
(
lastVo
)
}
else
{
console
.
log
(
"new"
)
this
.
emptyHexIndices
.
splice
(
this
.
emptyHexIndices
.
indexOf
(
vo
.
index
),
1
)
let
circleItem
=
this
.
objectPool
.
getItem
(
Math
.
floor
(
4
*
Math
.
random
()),
vo
.
p
,
vo
.
index
)
vo
.
item
=
circleItem
this
.
container
.
addChild
(
circleItem
)
this
.
circleItems
.
push
(
circleItem
)
setTimeout
(()
=>
{
this
.
drop
()
},
30
)
}
}
}
}
exchange
(
vo
:
CircleItem
,
p
:
point
)
{
FYGE
.
Tween
.
get
(
vo
).
to
({
x
:
p
.
x
,
y
:
p
.
y
},
30
).
call
(()
=>
{
vo
.
point
=
{
x
:
p
.
x
+
39
,
y
:
p
.
y
+
39
}
this
.
drop
()
})
}
getDistance
(
p1
:
point
,
p2
:
point
):
number
{
return
Math
.
abs
(
Math
.
sqrt
((
p2
.
x
-
p1
.
x
)
*
(
p2
.
x
-
p1
.
x
)
+
(
p2
.
y
-
p1
.
y
)
*
(
p2
.
y
-
p1
.
y
)))
}
findCircleItemByPos
(
p0
:
point
,
p1
:
point
):
CircleItem
{
for
(
let
co
of
this
.
circleItems
)
{
if
(
this
.
getDistance
(
co
.
point
,
p0
)
<
this
.
radius
*
1.5
&&
this
.
getDistance
(
p1
,
co
.
point
)
<
this
.
radius
/
3
)
{
// console.log(co, this.selectItems.indexOf(co))
if
(
this
.
selectItems
.
indexOf
(
co
)
==
-
1
)
{
return
co
}
else
{
// console.log(this.selectItems)
}
}
}
return
null
}
/**
*
* @param p 移动坐标
*/
findFirstCircleItemByPos
(
p
:
point
):
CircleItem
{
for
(
let
co
of
this
.
circleItems
)
{
if
(
this
.
getDistance
(
co
.
point
,
p
)
<
this
.
radius
/
3
)
{
if
(
this
.
selectItems
.
indexOf
(
co
)
==
-
1
)
{
return
co
}
}
}
return
null
}
/**
* row和col获得index值
* @param row
* @param col
*/
rcToIndex
(
row
:
number
,
col
:
number
):
number
{
var
key
=
""
+
row
+
col
;
return
this
.
rcToIndexMap
[
key
]
}
/**
* index获得row和col,返回的是数组,0是row,1是col
* @param index
*/
indexToRc
(
index
:
number
):
number
[]
{
return
this
.
indexToRcMap
[
index
]
}
/**
* 根据row,col得到位置信息
* @param row
* @param col
* @return 类似坐标
*/
getPositionByRc
(
row
:
number
,
col
:
number
):
point
{
var
key
=
""
+
row
+
col
;
return
this
.
rowColPositions
[
key
]
}
/**
* 根据index得到位置信息
* @param index
* @return 类似坐标
*/
getPositionByIndex
(
index
:
number
):
point
{
return
this
.
indexPositions
[
index
]
}
/**初始化场景元素 */
initSceneEle
()
{
// console.log(1111)
}
initEvents
()
{
var
that
=
this
;
console
.
log
(
"主场景添加事件"
)
this
.
addEventListener
(
FYGE
.
MouseEvent
.
MOUSE_DOWN
,
that
.
mouseDown
,
that
)
this
.
addEventListener
(
FYGE
.
MouseEvent
.
MOUSE_UP
,
that
.
mouseUp
,
that
);
// that.tlBtn.addEventListener(FYGE.MouseEvent.CLICK,()=>{that.changeMainScene(SCENETYPE.CLASSROOM)},that);
// that.mxqBtn.addEventListener(FYGE.MouseEvent.CLICK,()=>{that.changeMainScene(SCENETYPE.PLAYGROUND)},that);
// FYGE.GDispatcher.addEventListener(MSG.CHANGE_SCENE,()=>{that.changeMainScene(SCENETYPE.BEADROOM)},that);
}
// changeScene(MainScene);
removeEvents
()
{
var
that
=
this
;
console
.
log
(
"主场景移除事件"
)
this
.
removeEventListener
(
FYGE
.
MouseEvent
.
MOUSE_DOWN
,
that
.
mouseDown
,
that
)
this
.
removeEventListener
(
FYGE
.
MouseEvent
.
MOUSE_UP
,
that
.
mouseUp
,
that
);
// that.tlBtn.removeEventListener(FYGE.MouseEvent.CLICK,()=>{that.changeMainScene(SCENETYPE.CLASSROOM)},that);
// that.mxqBtn.removeEventListener(FYGE.MouseEvent.CLICK,()=>{that.changeMainScene(SCENETYPE.PLAYGROUND)},that);
// FYGE.GDispatcher.removeEventListener(MSG.CHANGE_SCENE,()=>{that.changeMainScene(SCENETYPE.BEADROOM)},that);
}
...
...
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