Skip to content

Commit

Permalink
FIX RemoteActionPositionController memory cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
kodlian committed Mar 18, 2018
1 parent fe5cfbe commit 252bed0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/RemoteActionPositionController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ class RemoteActionPositionController: NSObject, PositionController {

private let gamePad = GCController.controllers().first?.microGamepad

// MARK: Deinit
deinit {
gamePad?.dpad.valueChangedHandler = nil
}

// MARK: State
private var touchLocation: Location = .center {
didSet {
Expand Down Expand Up @@ -136,7 +141,7 @@ class RemoteActionPositionController: NSObject, PositionController {
// MARK: Surface Touch
private func trackSurfaceTouch() {
gamePad?.reportsAbsoluteDpadValues = true
gamePad?.dpad.valueChangedHandler = { (dpad: GCControllerDirectionPad, xValue: Float, yValue: Float) -> Void in
gamePad?.dpad.valueChangedHandler = { [unowned self] (dpad: GCControllerDirectionPad, xValue: Float, yValue: Float) -> Void in

if xValue > 0.5 {
self.touchLocation = .right
Expand Down

0 comments on commit 252bed0

Please sign in to comment.