amirrajan / rubymotion-applied

RubyMotion documentation provided by the community. Submit a pull request to the docs for a free one year indie subscription.
Apache License 2.0
49 stars 9 forks source link

ARKit Sample App/documentation #48

Open amirrajan opened 6 years ago

amirrajan commented 6 years ago

From Slack:

But how does it know I'm trying to implement the delegate for ARSKViewDelegate when I use class GameViewController < UIViewController

After some trial and error I got it to work. I missed setting the .delegate = self. However that resultet in my viewWillAppear only firering once (even if i kill app and restart). To solve this i had to do something like this


def viewDidLoad
super

NSLog("RM_AR_DEBUG viewDidLoad")

self.view = arsk_view @scene_view = arsk_view @scene_view.delegate = self

@game_scene = GameScene.sceneWithSize(arsk_view.size) @game_scene.scaleMode = SKSceneScaleModeAspectFit

arsk_view.presentScene(@game_scene)

arsk_view.showsFPS = true arsk_view.showsNodeCount = true end

def arsk_view @arsk_view ||= ARSKView.alloc.initWithFrame(screen_rect) end

def viewWillAppear(animated) super(animated)

NSLog("RM_AR_DEBUG viewWillAppear")

configuration = ARWorldTrackingConfiguration.new @scene_view.session.runWithConfiguration(configuration) end