Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sejong25
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Tear of Sejong
sejong25
Commits
b0014b67
Commit
b0014b67
authored
Jun 25, 2019
by
18신대성
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
단어끼리 충돌, 단어들이 가운데로 모임
parent
7e015638
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
4 deletions
+54
-4
wordBackground.png
assets/wordBackground.png
+0
-0
index.html
index.html
+1
-0
Word.js
script/Word.js
+12
-1
WordSpace.js
script/WordSpace.js
+16
-0
main.js
script/main.js
+25
-3
No files found.
assets/wordBackground.png
0 → 100644
View file @
b0014b67
1.61 KB
index.html
View file @
b0014b67
...
...
@@ -4,6 +4,7 @@
<meta
charset=
"utf-8"
/>
<script
src=
"script/phaser.js"
></script>
<script
src=
"script/Background.js"
></script>
<script
src=
"script/WordSpace.js"
></script>
<script
src=
"script/Word.js"
></script>
</head>
<body>
...
...
script/Word.js
View file @
b0014b67
...
...
@@ -7,7 +7,18 @@ class Word
generate
(
scene
)
{
scene
.
add
.
text
(
400
,
300
,
this
.
wordText
,
{
fontFamily
:
'
"궁서", 궁서체, serif
'
}).
setBackgroundColor
(
'
#FF00FF
'
);
var
randomX
=
Phaser
.
Math
.
Between
(
100
,
500
);
this
.
physicsObj
=
scene
.
physics
.
add
.
sprite
(
randomX
,
100
,
'
wordBackground
'
).
setScale
(
0.5
);
this
.
wordObj
=
scene
.
add
.
text
(
randomX
,
100
,
this
.
wordText
,
{
fontFamily
:
'
"궁서", 궁서체, serif
'
}).
setColor
(
'
#000000
'
);
this
.
wordObj
.
setOrigin
(
0.5
,
0.5
);
}
attract
(
wordSpeed
)
{
var
dist
=
Phaser
.
Math
.
Distance
.
Between
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
,
WordSpace
.
gravityPoint
.
x
,
WordSpace
.
gravityPoint
.
y
);
var
angle
=
Phaser
.
Math
.
Angle
.
Between
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
,
WordSpace
.
gravityPoint
.
x
,
WordSpace
.
gravityPoint
.
y
);
this
.
physicsObj
.
setVelocity
(
dist
*
Math
.
cos
(
angle
)
*
wordSpeed
,
dist
*
Math
.
sin
(
angle
)
*
wordSpeed
);
this
.
wordObj
.
setPosition
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
);
}
}
...
...
script/WordSpace.js
0 → 100644
View file @
b0014b67
var
WordSpace
=
WordSpace
||
{};
WordSpace
.
isImageLoaded
=
false
;
WordSpace
.
wordGroup
=
null
;
WordSpace
.
wordPhysicsGroup
=
null
;
WordSpace
.
gravityPoint
=
{
x
:
400
,
y
:
300
};
WordSpace
.
loadImage
=
function
(
scene
)
{
if
(
!
this
.
isImageLoaded
)
{
scene
.
load
.
image
(
'
wordBackground
'
,
'
assets/wordBackground.png
'
);
}
}
\ No newline at end of file
script/main.js
View file @
b0014b67
...
...
@@ -18,20 +18,42 @@ var config = {
var
game
=
new
Phaser
.
Game
(
config
);
var
tec
;
// load assets
function
preload
()
{
BackGround
.
loadImage
(
this
);
WordSpace
.
loadImage
(
this
);
}
function
create
()
{
BackGround
.
drawBrain
(
this
);
var
word
=
new
Word
(
'
살려주세요
'
);
word
.
generate
(
this
);
WordSpace
.
wordGroup
=
[];
WordSpace
.
wordPhysicsGroup
=
this
.
physics
.
add
.
group
();
this
.
time
.
addEvent
(
{
delay
:
2000
,
callback
:
function
()
{
word
=
new
Word
(
"
솽젠커
"
);
word
.
generate
(
this
);
WordSpace
.
wordGroup
.
push
(
word
);
this
.
physics
.
add
.
collider
(
word
.
physicsObj
,
WordSpace
.
wordPhysicsGroup
);
WordSpace
.
wordPhysicsGroup
.
add
(
word
.
physicsObj
);
},
callbackScope
:
this
,
repeat
:
10
}
);
}
function
update
()
{
for
(
i
=
0
;
i
<
WordSpace
.
wordGroup
.
length
;
i
++
)
{
WordSpace
.
wordGroup
[
i
].
attract
(
0.5
);
}
}
\ 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