diff --git a/Demo/GlideDemo.xcodeproj/xcshareddata/xcschemes/GlideDemo_iOS.xcscheme b/Demo/GlideDemo.xcodeproj/xcshareddata/xcschemes/GlideDemo_iOS.xcscheme index 6e022c4..1a80f64 100644 --- a/Demo/GlideDemo.xcodeproj/xcshareddata/xcschemes/GlideDemo_iOS.xcscheme +++ b/Demo/GlideDemo.xcodeproj/xcshareddata/xcschemes/GlideDemo_iOS.xcscheme @@ -31,7 +31,7 @@ iOS 14.0 / macOS 11.0 / tvOS 14.0

+ +

+ + + +

+

+ - + +

- Make a simple 2d platformer in half an hour, tutorial on YouTube: diff --git a/Sources/Input/Models/GameControllerInterface.swift b/Sources/Input/Models/GameControllerInterface.swift index 3c37701..3f82e2a 100644 --- a/Sources/Input/Models/GameControllerInterface.swift +++ b/Sources/Input/Models/GameControllerInterface.swift @@ -25,7 +25,7 @@ import Foundation -protocol GameControllerInterface: class { +protocol GameControllerInterface: AnyObject { associatedtype ExtendedGamepad: ExtendedGamepadInterface associatedtype MicroGamepad: MicroGamepadInterface @@ -54,13 +54,13 @@ protocol ExtendedGamepadInterface { var buttonMenu: Button { get } } -protocol GamepadButtonInterface: class { +protocol GamepadButtonInterface: AnyObject { associatedtype Button var pressedChangedHandler: ((Button, Float, Bool) -> Void)? { get set } } -protocol GamepadDirectionPadInterface: class { +protocol GamepadDirectionPadInterface: AnyObject { associatedtype DirectionPad var valueChangedHandler: ((DirectionPad, Float, Float) -> Void)? { get set } diff --git a/Sources/Scene/GlideScene.swift b/Sources/Scene/GlideScene.swift index 0dc3850..420ab96 100644 --- a/Sources/Scene/GlideScene.swift +++ b/Sources/Scene/GlideScene.swift @@ -165,7 +165,12 @@ open class GlideScene: SKScene { return node }() - var isDebuggingCollisionTileMapNode: Bool = false { + /// Whether the collision tile map should be drawn or not. + /// Default value is `false`. + /// Compiler `DEBUG` flag should on for this to work. + /// A texture atlas for collision tiles should be provided + /// for loading collider tile map from a Tiled Map Editor file. + public var isDebuggingCollisionTileMapNode: Bool = false { didSet { updateCollisionTileMapNodeDebug() } diff --git a/Sources/Scene/GlideSceneDelegate.swift b/Sources/Scene/GlideSceneDelegate.swift index f56defe..ee7f03e 100644 --- a/Sources/Scene/GlideSceneDelegate.swift +++ b/Sources/Scene/GlideSceneDelegate.swift @@ -25,7 +25,7 @@ import Foundation -public protocol GlideSceneDelegate: class { +public protocol GlideSceneDelegate: AnyObject { /// Called when the paused states of the scene changes. func glideScene(_ scene: GlideScene, didChangePaused paused: Bool) diff --git a/Sources/TiledMapEditorSceneLoader/TiledMapEditorSceneLoader.swift b/Sources/TiledMapEditorSceneLoader/TiledMapEditorSceneLoader.swift index a3860e8..0da2646 100644 --- a/Sources/TiledMapEditorSceneLoader/TiledMapEditorSceneLoader.swift +++ b/Sources/TiledMapEditorSceneLoader/TiledMapEditorSceneLoader.swift @@ -210,7 +210,11 @@ public class TiledMapEditorSceneLoader { continue } let textureName = String(rawTextureName) - let textureFromAtlas = collisionTilesTextureAtlas?.textureNamed(textureName) ?? decorationTilesTextureAtlas?.textureNamed(textureName) + + var textureFromAtlas = collisionTilesTextureAtlas?.textureNames.contains(textureName) == true ? collisionTilesTextureAtlas?.textureNamed(textureName) : nil + if textureFromAtlas == nil { + textureFromAtlas = decorationTilesTextureAtlas?.textureNames.contains(textureName) == true ? decorationTilesTextureAtlas?.textureNamed(textureName) : nil + } let texture = textureFromAtlas ?? SKTexture(imageNamed: textureName) texture.filteringMode = .nearest @@ -272,8 +276,7 @@ public class TiledMapEditorSceneLoader { var matchingTileSet: LoadedTileSet? for tileSet in tileSets { - let tileIndex = firstNonEmptyTileIndex - tileSet.firstGid - if case tileSet.range = tileIndex { + if firstNonEmptyTileIndex < tileSet.range.endIndex { matchingTileSet = tileSet break } diff --git a/Sources/UI/Model/NavigatableElement.swift b/Sources/UI/Model/NavigatableElement.swift index 83b5d14..854c38b 100644 --- a/Sources/UI/Model/NavigatableElement.swift +++ b/Sources/UI/Model/NavigatableElement.swift @@ -26,7 +26,7 @@ import Foundation /// Protocol to adopt for custom navigatable view classes. -public protocol NavigatableElement: class { +public protocol NavigatableElement: AnyObject { /// Navigatable sibling element that's positioned above this element. var upElement: NavigatableElement? { get set } /// Navigatable sibling element that's positioned below this element. diff --git a/Sources/UI/View/NavigatableButtonContentView.swift b/Sources/UI/View/NavigatableButtonContentView.swift index 1b8f7f0..7c38843 100644 --- a/Sources/UI/View/NavigatableButtonContentView.swift +++ b/Sources/UI/View/NavigatableButtonContentView.swift @@ -26,7 +26,7 @@ import Foundation /// Protocol to adopt for custom content view classes of navigatable buttons. -public protocol NavigatableButtonContentView: class { +public protocol NavigatableButtonContentView: AnyObject { var isSelected: Bool { get set } var isFocusedElement: Bool { get set } var isTouchedDown: Bool { get set } diff --git a/Sources/iOS/TouchReceiverComponent.swift b/Sources/iOS/TouchReceiverComponent.swift index 1a04da1..fd9c28c 100644 --- a/Sources/iOS/TouchReceiverComponent.swift +++ b/Sources/iOS/TouchReceiverComponent.swift @@ -29,7 +29,7 @@ import GameplayKit /// When adopted, component's entity will be able to manage touch inputs /// on an iOS device. -public protocol TouchReceiverComponent: class { +public protocol TouchReceiverComponent: AnyObject { /// Node for testing the hits of touches from the screen. /// This should be a node with a non empty parent. diff --git a/Tests/CollisionsTests/Ground Collisions/CollisionsController+GroundCollisionsTests.swift b/Tests/CollisionsTests/Ground Collisions/CollisionsController+GroundCollisionsTests.swift index d3e4e2c..0e2eb1d 100644 --- a/Tests/CollisionsTests/Ground Collisions/CollisionsController+GroundCollisionsTests.swift +++ b/Tests/CollisionsTests/Ground Collisions/CollisionsController+GroundCollisionsTests.swift @@ -164,7 +164,7 @@ class CollisionsControllerGroundCollisionsTests: XCTestCase { return } - _ = collisionsController.handleJumpWallTileContact(colliderMovement: colliderMovement, isJumpWallLeft: true, shouldCollideGround: true, tileIntersection: jumpWallIntersection) + collisionsController.handleJumpWallTileContact(colliderMovement: colliderMovement, isJumpWallLeft: true, shouldCollideGround: true, tileIntersection: jumpWallIntersection) XCTAssertTrue(colliderMovement.collider.pushesLeftJumpWall) } @@ -186,7 +186,7 @@ class CollisionsControllerGroundCollisionsTests: XCTestCase { return } - _ = collisionsController.handleJumpWallTileContact(colliderMovement: colliderMovement, isJumpWallLeft: false, shouldCollideGround: true, tileIntersection: jumpWallIntersection) + collisionsController.handleJumpWallTileContact(colliderMovement: colliderMovement, isJumpWallLeft: false, shouldCollideGround: true, tileIntersection: jumpWallIntersection) XCTAssertTrue(colliderMovement.collider.pushesRightJumpWall) } }