Skip to content

Commit

Permalink
Fix access modifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
phuocpeter committed Jun 11, 2018
1 parent cdfe1e0 commit 5d795a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
22 changes: 11 additions & 11 deletions SKGamePad/SKColorButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import SpriteKit
/**
A retangular color sprite that register touch events.
*/
class SKColorButton: SKSpriteNode {
public class SKColorButton: SKSpriteNode {
/** The touch listener of the sprite. */
var listener: SKColorButtonTouchesListener?
public var listener: SKColorButtonTouchesListener?

required init?(coder aDecoder: NSCoder) {
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}

override init(texture: SKTexture?, color: UIColor, size: CGSize) {
override public init(texture: SKTexture?, color: UIColor, size: CGSize) {
super.init(texture: nil, color: color, size: size)
self.isUserInteractionEnabled = true
}
Expand All @@ -31,7 +31,7 @@ class SKColorButton: SKSpriteNode {
- color: the color of the button.
- size: the size of the button.
*/
convenience init(name: String, color: UIColor, size: CGSize) {
convenience public init(name: String, color: UIColor, size: CGSize) {
self.init(texture: nil, color: color, size: size)
self.name = name
}
Expand All @@ -40,28 +40,28 @@ class SKColorButton: SKSpriteNode {

// Touch events handling.
extension SKColorButton {
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
override public func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if touches.first != nil {
listener?.buttonTouched(button: self, withState: .begun)
}
super.touchesBegan(touches, with: event)
}

override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
override public func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
if touches.first != nil {
listener?.buttonTouched(button: self, withState: .ended)
}
super.touchesEnded(touches, with: event)
}

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
override public func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
if touches.first != nil {
listener?.buttonTouched(button: self, withState: .moved)
}
super.touchesMoved(touches, with: event)
}

override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
override public func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
if touches.first != nil {
listener?.buttonTouched(button: self, withState: .cancelled)
}
Expand All @@ -70,7 +70,7 @@ extension SKColorButton {
}

/** Touch event states of the button. */
enum SKColorButtonTouchEvent {
public enum SKColorButtonTouchEvent {
/** The button is touched. */
case begun
/** The button is released. */
Expand All @@ -82,7 +82,7 @@ enum SKColorButtonTouchEvent {
}

/** Listener for button's touch event notifications. */
protocol SKColorButtonTouchesListener {
public protocol SKColorButtonTouchesListener {
/**
Notifies that the button is touched.
- parameters:
Expand Down
16 changes: 8 additions & 8 deletions SKGamePad/SKDirectionalPad.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import SpriteKit

/** Delegate for notification of directional button touch events. */
protocol SKDirectionalPadDelegate {
public protocol SKDirectionalPadDelegate {
/**
Notifies the event from the up button.
- parameters:
Expand All @@ -36,9 +36,9 @@ protocol SKDirectionalPadDelegate {
/**
A node containing the directional pad.
*/
class SKDirectionalPad: SKNode {
public class SKDirectionalPad: SKNode {
/** Delegate for notification of button touch events. */
var delegate: SKDirectionalPadDelegate?
public var delegate: SKDirectionalPadDelegate?

var padColor: UIColor
var padSize: CGSize
Expand All @@ -49,7 +49,7 @@ class SKDirectionalPad: SKNode {
var rightPad: SKColorButton!

/** Initiliazes from NSCoder. */
required init?(coder aDecoder: NSCoder) {
required public init?(coder aDecoder: NSCoder) {
padColor = UIColor.lightGray
padSize = CGSize(width: 50, height: 50)
super.init(coder: aDecoder)
Expand All @@ -62,7 +62,7 @@ class SKDirectionalPad: SKNode {
- color: the color of the button.
- size: the size of the individual button.
*/
init(padColor color: UIColor, padSize size: CGSize) {
public init(padColor color: UIColor, padSize size: CGSize) {
self.padColor = color
self.padSize = size
super.init()
Expand Down Expand Up @@ -98,7 +98,7 @@ class SKDirectionalPad: SKNode {
- parameters:
- visibleSize: the CGSize object of the visible size of the device screen.
*/
func setPositionToBottomLeft(view: SKView) {
public func setPositionToBottomLeft(view: SKView) {
let visibleSize = view.bounds.size
/** Insets specifically for new iPhone. */
var insets: UIEdgeInsets {
Expand All @@ -117,7 +117,7 @@ class SKDirectionalPad: SKNode {

// Redirects button events to delegate
extension SKDirectionalPad: SKColorButtonTouchesListener {
func buttonTouched(button: SKColorButton, withState state: SKColorButtonTouchEvent) {
public func buttonTouched(button: SKColorButton, withState state: SKColorButtonTouchEvent) {
// Identifies the button by name.
guard let name = button.name else { return }
// Compares the button name with the enumeration.
Expand All @@ -138,7 +138,7 @@ extension SKDirectionalPad: SKColorButtonTouchesListener {
}

/** Convenience enumeration of conventional directional buttons. */
enum SKDirectionalPadButtons: String {
public enum SKDirectionalPadButtons: String {
/** Pointing upward button. */
case upButton
/** Pointing downward button. */
Expand Down

0 comments on commit 5d795a5

Please sign in to comment.