Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
learn-phaser
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
learn-phaser
Commits
18ebc83d
Commit
18ebc83d
authored
Apr 21, 2018
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
d384b84c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
30 deletions
+32
-30
PieceControl.ts
dogborn/src/PieceControl.ts
+2
-2
SceneControl.ts
dogborn/src/SceneControl.ts
+30
-28
No files found.
dogborn/src/PieceControl.ts
View file @
18ebc83d
...
@@ -2,8 +2,8 @@ export default class PieceControl {
...
@@ -2,8 +2,8 @@ export default class PieceControl {
public
scene
;
public
scene
;
private
isDog
:
boolean
;
private
isDog
:
boolean
;
private
front
;
private
front
;
p
rivate
back
;
p
ublic
back
;
p
rivate
index
:
number
;
p
ublic
index
:
number
;
static
FLIP_DURTION
=
1000
;
static
FLIP_DURTION
=
1000
;
public
container
;
public
container
;
...
...
dogborn/src/SceneControl.ts
View file @
18ebc83d
...
@@ -9,7 +9,7 @@ export default class SceneControl {
...
@@ -9,7 +9,7 @@ export default class SceneControl {
SHOW_TIME
=
1000
;
SHOW_TIME
=
1000
;
DELAY
=
500
;
DELAY
=
500
;
BORNS
=
2
;
BORNS
=
1
;
R
=
3
;
R
=
3
;
TIMES
=
3
;
TIMES
=
3
;
N
=
4
;
N
=
4
;
...
@@ -22,40 +22,42 @@ export default class SceneControl {
...
@@ -22,40 +22,42 @@ export default class SceneControl {
}
}
initUI
()
{
initUI
()
{
const
n
=
this
.
R
*
this
.
R
;
const
n
=
this
.
R
*
this
.
R
;
const
targetList
=
utils
.
fillN
(
n
);
const
targetList
=
utils
.
fillN
(
n
);
const
randomTargetList
=
utils
.
shuffle
(
targetList
);
const
randomTargetList
=
utils
.
shuffle
(
targetList
);
this
.
_targets
=
randomTargetList
.
slice
(
0
,
this
.
BORNS
);
this
.
_targets
=
randomTargetList
.
slice
(
0
,
this
.
BORNS
);
this
.
_list
=
[];
this
.
_list
=
[];
for
(
let
index
=
1
;
index
<=
n
;
index
++
)
{
for
(
let
index
=
1
;
index
<=
n
;
index
++
)
{
const
inTargets
=
this
.
_targets
.
indexOf
(
index
)
!=
-
1
;
const
inTargets
=
this
.
_targets
.
indexOf
(
index
)
!=
-
1
;
const
p
=
new
PieceControl
(
this
.
scene
,
!
inTargets
,
index
);
const
p
=
new
PieceControl
(
this
.
scene
,
!
inTargets
,
index
);
p
.
back
.
setInteractive
();
p
[
'index'
]
=
index
;
p
[
'index'
]
=
index
;
this
.
_list
.
push
(
p
);
this
.
_list
.
push
(
p
);
p
.
container
.
x
=
((
index
-
1
)
%
this
.
R
)
*
this
.
SIZE
+
106
+
50
;
p
.
container
.
x
=
((
index
-
1
)
%
this
.
R
)
*
this
.
SIZE
+
106
+
50
;
p
.
container
.
y
=
Math
.
floor
((
index
-
1
)
/
this
.
R
)
*
this
.
SIZE
+
106
+
50
;
p
.
container
.
y
=
Math
.
floor
((
index
-
1
)
/
this
.
R
)
*
this
.
SIZE
+
106
+
50
;
p
.
flipImmediately
();
p
.
flipImmediately
();
// p.addEventListener('click', (e: createjs.MouseEvent) => {
p
.
back
.
on
(
'clicked'
,
()
=>
{
// const p = (e.currentTarget as Piece);
// console.log(p.index);
// this.disable();
this
.
disable
();
// let enable = false;
let
enable
=
false
;
// const index = this._targets.indexOf(p.index);
const
index
=
this
.
_targets
.
indexOf
(
p
.
index
);
// if (index != -1) {
if
(
index
!=
-
1
)
{
// this._targets.splice(index, 1);
this
.
_targets
.
splice
(
index
,
1
);
// if (this._targets.length == 0) {
if
(
this
.
_targets
.
length
==
0
)
{
// console.log('good.')
console
.
log
(
'good.'
)
// } else {
}
else
{
// enable = true;
enable
=
true
;
// }
}
// }
}
// else {
else
{
// console.log('sorry.')
console
.
log
(
'sorry.'
)
// }
}
// p.flip(() => {
p
.
flip
(()
=>
{
// if (enable) this.enable();
if
(
enable
)
this
.
enable
();
// });
});
},
this
);
// });
}
}
this
.
disable
();
this
.
disable
();
...
@@ -84,14 +86,14 @@ export default class SceneControl {
...
@@ -84,14 +86,14 @@ export default class SceneControl {
}
}
disable
()
{
disable
()
{
// for (const e of this._list) {
this
.
scene
.
input
.
off
(
'gameobjectup'
,
this
.
ongameobjectup
,
this
);
// e.mouseEnabled = false;
// }
}
}
enable
()
{
enable
()
{
// for (const e of this._list) {
this
.
scene
.
input
.
on
(
'gameobjectup'
,
this
.
ongameobjectup
,
this
);
// e.mouseEnabled = true;
}
// }
ongameobjectup
(
pointer
,
gameObject
){
gameObject
.
emit
(
'clicked'
,
gameObject
);
}
}
}
}
\ 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