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
f56d7b42
Commit
f56d7b42
authored
Jul 04, 2019
by
18류지석
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
물리 WIP
parent
839254ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
WordObject.js
js/WordObject.js
+12
-4
WordSpace.js
js/WordSpace.js
+1
-1
No files found.
js/WordObject.js
View file @
f56d7b42
...
...
@@ -9,7 +9,7 @@ class WordObject
this
.
wordGrade
=
WordReader
.
getWordGrade
(
this
.
wordTyping
);
this
.
wordWeight
=
WordReader
.
getWordWeight
(
this
.
wordGrade
);
//console.log("wordTyping : " + this.wordTyping + '\n' + "wordGrade : " + this.wordGrade + '\n' + "wordWeight : " + this.wordWeight + '\n');
this
.
wordSpeed
=
1
;
this
.
wordSpeed
=
0.5
;
}
instantiate
(
scene
,
lenRate
)
...
...
@@ -20,7 +20,8 @@ class WordObject
var
random
=
WordSpace
.
getSpawnPoint
(
lenRate
);
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
)
.
setScale
(
scale
);
.
setScale
(
scale
)
.
setBounce
(
0.5
);
this
.
wordObj
=
scene
.
add
.
text
(
random
.
x
,
random
.
y
,
this
.
wordText
,
{
...
...
@@ -49,8 +50,15 @@ class WordObject
attract
()
{
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
);
let
gravityScale
=
0.1
;
let
accel
=
{
x
:
0
,
y
:
0
};
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
);
accel
.
x
+=
Math
.
pow
(
dist
,
2
)
*
gravityScale
*
Math
.
cos
(
angle
);
accel
.
y
+=
Math
.
pow
(
dist
,
2
)
*
gravityScale
*
Math
.
sin
(
angle
);
this
.
physicsObj
.
setVelocity
(
dist
*
Math
.
cos
(
angle
)
*
this
.
wordSpeed
,
dist
*
Math
.
sin
(
angle
)
*
this
.
wordSpeed
);
this
.
wordObj
.
setPosition
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
);
this
.
physicsObj
.
setVelocity
(
dist
*
Math
.
cos
(
angle
)
*
this
.
wordSpeed
,
dist
*
Math
.
sin
(
angle
)
*
this
.
wordSpeed
);
this
.
wordObj
.
setPosition
(
this
.
physicsObj
.
x
,
this
.
physicsObj
.
y
);
}
...
...
js/WordSpace.js
View file @
f56d7b42
...
...
@@ -290,7 +290,7 @@ WordSpace.generateWord = function(scene, wordText, grade, lenRate)
word
.
physicsObj
.
topObj
=
word
;
scene
.
physics
.
add
.
collider
(
word
.
physicsObj
,
WordSpace
.
wordPhysicsGroup
,
function
(
object1
)
{
object1
.
topObj
.
wordSpeed
=
0.1
;
//
object1.topObj.wordSpeed = 0.1;
object1
.
topObj
.
attract
();
});
WordSpace
.
wordPhysicsGroup
.
add
(
word
.
physicsObj
);
...
...
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