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
bd8fa049
Commit
bd8fa049
authored
Jul 07, 2019
by
18류지석
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
물리 해결
parent
305c3726
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
WordObject.js
js/WordObject.js
+14
-7
No files found.
js/WordObject.js
View file @
bd8fa049
...
...
@@ -21,13 +21,17 @@ class WordObject
this
.
physicsObj
=
scene
.
physics
.
add
.
sprite
(
random
.
x
,
random
.
y
,
'
wordBgr
'
+
this
.
wordGrade
+
'
_
'
+
Math
.
min
(
Math
.
max
(
2
,
this
.
wordText
.
length
),
6
))
.
setMass
(
this
.
wordWeight
*
10
)
.
setScale
(
scale
)
.
setFrictionX
(
0.5
)
.
setFrictionY
(
0.5
);
.
setFrictionX
(
0
)
.
setFrictionY
(
0
)
.
setBounce
(
0.5
);
let
dist
=
Phaser
.
Math
.
Distance
.
Between
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
,
WordSpace
.
gravityPoint
.
x
,
WordSpace
.
gravityPoint
.
y
);
let
angle
=
Phaser
.
Math
.
Angle
.
Between
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
,
WordSpace
.
gravityPoint
.
x
,
WordSpace
.
gravityPoint
.
y
);
this
.
physicsObj
.
setVelocity
(
100
*
Math
.
cos
(
angle
),
100
*
Math
.
sin
(
angle
));
//임시땜빵
this
.
moveStarted
=
false
;
this
.
initSpeed
=
{
x
:
200
*
Math
.
cos
(
angle
),
y
:
200
*
Math
.
sin
(
angle
)};
this
.
wordObj
=
scene
.
add
.
text
(
random
.
x
,
random
.
y
,
this
.
wordText
,
{
...
...
@@ -39,8 +43,6 @@ class WordObject
WordSpace
.
totalWordNum
+=
1
;
WordSpace
.
setGameOverTimer
();
//console.log("Total weight : " + WordSpace.totalWeight);
console
.
log
(
this
.
physicsObj
.
body
.
velocity
.
x
);
}
destroy
()
...
...
@@ -59,14 +61,19 @@ class WordObject
attract
()
{
let
gravityScale
=
0.5
,
velocityLimit
;
if
(
!
this
.
moveStarted
)
{
this
.
moveStarted
=
true
;
this
.
physicsObj
.
setVelocity
(
this
.
initSpeed
.
x
,
this
.
initSpeed
.
y
);
}
let
gravityScale
=
0.8
,
velocityLimit
;
let
accel
=
{
x
:
this
.
physicsObj
.
body
.
velocity
.
x
,
y
:
this
.
physicsObj
.
body
.
velocity
.
y
};
let
dist
,
angle
;
let
vel
;
dist
=
Phaser
.
Math
.
Distance
.
Between
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
,
WordSpace
.
gravityPoint
.
x
,
WordSpace
.
gravityPoint
.
y
);
angle
=
Phaser
.
Math
.
Angle
.
Between
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
,
WordSpace
.
gravityPoint
.
x
,
WordSpace
.
gravityPoint
.
y
);
velocityLimit
=
dist
+
10
;
velocityLimit
=
dist
*
0.9
;
accel
.
x
+=
gravityScale
*
Math
.
cos
(
angle
);
accel
.
y
+=
gravityScale
*
Math
.
sin
(
angle
);
...
...
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