Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
interactiveGames_Level
Project
Project
Details
Activity
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
xuxing@jiuaoedu.com
interactiveGames_Level
Commits
18642d0e
Commit
18642d0e
authored
Nov 01, 2021
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
邻接数组块好了
parent
a4390be3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
8 deletions
+29
-8
AdjacentArrayCtr.ts
...ceneBundle/games/adjacentArray/script/AdjacentArrayCtr.ts
+29
-8
No files found.
assets/sceneBundle/games/adjacentArray/script/AdjacentArrayCtr.ts
View file @
18642d0e
...
...
@@ -49,7 +49,7 @@ export class AdjacentArrayCtr extends Component {
private
itemSpaceY
=
10
;
private
itemPosIfoArr
:
ItemPosIfo
[]
=
[];
private
row
=
5
;
private
column
=
5
;
private
column
=
6
;
private
gridIfoArr
:
GridIfo
[]
=
[];
...
...
@@ -70,12 +70,34 @@ export class AdjacentArrayCtr extends Component {
console
.
log
(
`grid被点击`
);
console
.
log
(
event
.
target
)
let
grid
=
this
.
findGridInGridArr
(
<
Node
>
event
.
target
)
!
;
grid
.
active
=
true
;
grid
.
gridItem
.
active
=
true
;
console
.
log
(
`选中格子`
);
console
.
log
(
grid
.
gridItem
);
grid
.
pairItem
[
0
].
target
.
getComponent
(
AdjacentArrayItemCtr
)?.
setBgSprToSel
();
grid
.
pairItem
[
1
].
target
.
getComponent
(
AdjacentArrayItemCtr
)?.
setBgSprToSel
();
grid
.
active
=
!
grid
.
active
;
if
(
grid
.
active
)
{
console
.
log
(
`选中格子`
);
console
.
log
(
grid
.
gridItem
);
//先去掉
let
o_gridArr
=
this
.
findGridInGridArrWithItem
(
grid
.
pairItem
[
0
]);
o_gridArr
=
o_gridArr
.
concat
(
this
.
findGridInGridArrWithItem
(
grid
.
pairItem
[
1
]));
for
(
let
i
=
0
;
i
<
o_gridArr
.
length
;
++
i
)
{
if
(
!
o_gridArr
[
i
].
active
)
continue
;
o_gridArr
[
i
].
active
=
false
;
o_gridArr
[
i
].
gridItem
.
active
=
false
;
o_gridArr
[
i
].
pairItem
[
0
].
target
.
getComponent
(
AdjacentArrayItemCtr
)?.
setBgSprToNor
();
o_gridArr
[
i
].
pairItem
[
1
].
target
.
getComponent
(
AdjacentArrayItemCtr
)?.
setBgSprToNor
();
}
grid
.
gridItem
.
active
=
true
;
grid
.
active
=
true
;
grid
.
pairItem
[
0
].
target
.
getComponent
(
AdjacentArrayItemCtr
)?.
setBgSprToSel
();
grid
.
pairItem
[
1
].
target
.
getComponent
(
AdjacentArrayItemCtr
)?.
setBgSprToSel
();
}
else
{
grid
.
gridItem
.
active
=
false
;
grid
.
active
=
false
;
console
.
log
(
`选中格子`
);
console
.
log
(
grid
.
gridItem
);
grid
.
pairItem
[
0
].
target
.
getComponent
(
AdjacentArrayItemCtr
)?.
setBgSprToNor
();
grid
.
pairItem
[
1
].
target
.
getComponent
(
AdjacentArrayItemCtr
)?.
setBgSprToNor
();
}
}
creAllItem
()
{
...
...
@@ -158,7 +180,6 @@ export class AdjacentArrayCtr extends Component {
let
gridSpr
=
instantiate
(
this
.
gridPre
).
getComponent
(
Sprite
)
!
;
gridSpr
.
node
.
getComponent
(
UITransform
)
!
.
width
=
this
.
itemWidth
*
2
+
this
.
itemSpaceX
;
gridSpr
.
node
.
getComponent
(
UITransform
)
!
.
height
=
this
.
itemHeight
;
gridSpr
.
node
.
layer
=
1
<<
25
;
this
.
gridArrNode
.
addChild
(
gridSpr
.
node
);
gridSpr
.
node
.
active
=
false
;
gridSpr
.
node
.
setPosition
((
s_pos
.
x
+
e_pos
.
x
)
/
2
,
(
s_pos
.
y
+
e_pos
.
y
)
/
2
);
...
...
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