Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Pacman3D-iOS
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Ullerich
Pacman3D-iOS
Commits
e786ddd5
Commit
e786ddd5
authored
7 years ago
by
Francois Bertrand
Browse files
Options
Downloads
Patches
Plain Diff
Add Accelerometer movement, Changed Packman Camera
parent
616cda23
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Pacman3D-iOS/GameViewController.swift
+27
-2
27 additions, 2 deletions
Pacman3D-iOS/GameViewController.swift
Pacman3D-iOS/art.scnassets/Pacman.dae
+4
-4
4 additions, 4 deletions
Pacman3D-iOS/art.scnassets/Pacman.dae
with
31 additions
and
6 deletions
Pacman3D-iOS/GameViewController.swift
+
27
−
2
View file @
e786ddd5
...
@@ -9,9 +9,14 @@
...
@@ -9,9 +9,14 @@
import
UIKit
import
UIKit
import
QuartzCore
import
QuartzCore
import
SceneKit
import
SceneKit
import
CoreMotion
class
GameViewController
:
UIViewController
{
class
GameViewController
:
UIViewController
{
var
motionManager
:
CMMotionManager
?
var
isRotating
:
Bool
=
false
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
...
@@ -71,6 +76,26 @@ class GameViewController: UIViewController {
...
@@ -71,6 +76,26 @@ class GameViewController: UIViewController {
// add a tap gesture recognizer
// add a tap gesture recognizer
let
tapGesture
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector
(
handleTap
(
_
:)))
let
tapGesture
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector
(
handleTap
(
_
:)))
scnView
.
addGestureRecognizer
(
tapGesture
)
scnView
.
addGestureRecognizer
(
tapGesture
)
motionManager
=
CMMotionManager
()
if
(
motionManager
?
.
isAccelerometerAvailable
)
!
{
motionManager
?
.
accelerometerUpdateInterval
=
0.1
motionManager
?
.
startAccelerometerUpdates
(
to
:
OperationQueue
.
main
,
withHandler
:
{
(
data
,
error
)
in
let
rotate
=
data
!.
acceleration
.
y
//print(rotate)
let
pacman
=
scene
.
rootNode
.
childNode
(
withName
:
"Pacman"
,
recursively
:
true
)
!
let
direction
:
Float
=
rotate
<
0
?
1.0
:
-
1.0
if
abs
(
rotate
)
>
0.3
{
if
!
self
.
isRotating
{
let
action
=
SCNAction
.
rotateBy
(
x
:
0
,
y
:
CGFloat
(
direction
*
Float
.
pi
*
0.5
),
z
:
0
,
duration
:
0.25
)
pacman
.
runAction
(
action
)
self
.
isRotating
=
true
}
}
else
{
self
.
isRotating
=
false
}
})
}
}
}
func
handleTap
(
_
gestureRecognize
:
UIGestureRecognizer
)
{
func
handleTap
(
_
gestureRecognize
:
UIGestureRecognizer
)
{
...
@@ -109,7 +134,7 @@ class GameViewController: UIViewController {
...
@@ -109,7 +134,7 @@ class GameViewController: UIViewController {
}
}
override
var
shouldAutorotate
:
Bool
{
override
var
shouldAutorotate
:
Bool
{
return
fals
e
return
tru
e
}
}
override
var
prefersStatusBarHidden
:
Bool
{
override
var
prefersStatusBarHidden
:
Bool
{
...
@@ -118,7 +143,7 @@ class GameViewController: UIViewController {
...
@@ -118,7 +143,7 @@ class GameViewController: UIViewController {
override
var
supportedInterfaceOrientations
:
UIInterfaceOrientationMask
{
override
var
supportedInterfaceOrientations
:
UIInterfaceOrientationMask
{
if
UIDevice
.
current
.
userInterfaceIdiom
==
.
phone
{
if
UIDevice
.
current
.
userInterfaceIdiom
==
.
phone
{
return
.
portrait
return
.
landscape
}
else
{
}
else
{
return
.
all
return
.
all
}
}
...
...
This diff is collapsed.
Click to expand it.
Pacman3D-iOS/art.scnassets/Pacman.dae
+
4
−
4
View file @
e786ddd5
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
<contributor>
<contributor>
<authoring_tool>
SceneKit Collada Exporter v1.0
</authoring_tool>
<authoring_tool>
SceneKit Collada Exporter v1.0
</authoring_tool>
</contributor>
</contributor>
<created>
2017-06-19T1
3:19:41
Z
</created>
<created>
2017-06-19T1
5:47:15
Z
</created>
<modified>
2017-06-19T1
3:19:41
Z
</modified>
<modified>
2017-06-19T1
5:47:15
Z
</modified>
<unit
meter=
"1.000000"
/>
<unit
meter=
"1.000000"
/>
<up_axis>
Z_UP
</up_axis>
<up_axis>
Z_UP
</up_axis>
</asset>
</asset>
...
@@ -148,7 +148,7 @@
...
@@ -148,7 +148,7 @@
<library_visual_scenes>
<library_visual_scenes>
<visual_scene
id=
"scene5"
>
<visual_scene
id=
"scene5"
>
<node
id=
"Sphere"
name=
"Sphere"
>
<node
id=
"Sphere"
name=
"Sphere"
>
<matrix>
1.580022 0 0 0 0 -6.9065e-08 -1.580022
0
0 1.580022 -6.9065e-08
0
0 0 0 1
</matrix>
<matrix>
1.580022 0 0 0 0 -6.9065e-08 -1.580022
7.33742e-11
0 1.580022 -6.9065e-08
-0.001678586
0 0 0 1
</matrix>
<instance_geometry
url=
"#Sphere-mesh"
>
<instance_geometry
url=
"#Sphere-mesh"
>
<bind_material>
<bind_material>
<technique_common>
<technique_common>
...
@@ -159,7 +159,7 @@
...
@@ -159,7 +159,7 @@
</instance_geometry>
</instance_geometry>
</node>
</node>
<node
id=
"Camera_001"
name=
"Camera_001"
>
<node
id=
"Camera_001"
name=
"Camera_001"
>
<matrix>
0.00942
820
3 0.
3446076 -0.9386549
-
5
.0
94206
-0.9999
211
0.00
324893 -0.008850717 0.0210471 -3.576155e-07 0.9387442 0.3446054 2.326969
0 0 0 1
</matrix>
<matrix>
0.00942
71
3 0.
2635223 -0.9645737
-
6
.0
61088
-0.9999
358
0.00
2483249 -0.009094264 0.01192989 -9.834569e-07 0.9646677 0.2635197 2.681937
0 0 0 1
</matrix>
<instance_camera
url=
"#Camera_001-camera"
/>
<instance_camera
url=
"#Camera_001-camera"
/>
</node>
</node>
</visual_scene>
</visual_scene>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment