-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ (GameEngineKit): Refactor the way to handle dropZones in BaseScene
- Loading branch information
Showing
3 changed files
with
58 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,21 +2,19 @@ | |
// Copyright 2023 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import ContentKit | ||
import SpriteKit | ||
import SwiftUI | ||
|
||
final class DragAndDropOneZoneScene: DragAndDropBaseScene { | ||
override func layoutDropZones(dropZones: DropZoneDetails...) { | ||
override func layoutDropZones() { | ||
// TODO(@hugo): Add type declaration | ||
Check failure on line 9 in Modules/GameEngineKit/Sources/_NewSystem/Views/DragAndDrop/OneZone/DragAndDropOneZoneScene.swift GitHub Actions / lint
|
||
let dropZoneNode = SKSpriteNode() | ||
let dropZoneSize = CGSize(width: 380, height: 280) | ||
dropZoneNode.size = dropZoneSize | ||
dropZoneNode.texture = SKTexture(imageNamed: dropZones[0].value) | ||
dropZoneNode.texture = SKTexture(imageNamed: dropZoneA.details.value) | ||
dropZoneNode.position = CGPoint(x: size.width / 2, y: dropZoneSize.height / 2) | ||
dropZoneNode.name = dropZones[0].value | ||
dropZoneNode.name = dropZoneA.details.value | ||
addChild(dropZoneNode) | ||
|
||
dropZoneNodes.append(dropZoneNode) | ||
dropZoneA.node = dropZoneNode | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,28 +2,36 @@ | |
// Copyright 2023 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import ContentKit | ||
import SpriteKit | ||
import SwiftUI | ||
|
||
final class DragAndDropTwoZonesScene: DragAndDropBaseScene { | ||
override func layoutDropZones(dropZones: DropZoneDetails...) { | ||
// TODO(@hugo): Add type declaration | ||
let dropZoneSpacer = size.width / 4 | ||
var dropZonePosition = dropZoneSpacer | ||
for dropZone in dropZones { | ||
let dropZoneNode = SKSpriteNode() | ||
// TODO(@hugo): Adapt size to final images given by the Design team | ||
let dropZoneSize = CGSize(width: 280, height: 280) | ||
dropZoneNode.size = dropZoneSize | ||
dropZoneNode.texture = SKTexture(imageNamed: dropZone.value) | ||
dropZoneNode.position = CGPoint(x: dropZonePosition, y: dropZoneSize.height / 2) | ||
dropZoneNode.name = dropZone.value | ||
addChild(dropZoneNode) | ||
|
||
dropZoneNodes.append(dropZoneNode) | ||
|
||
dropZonePosition += 2 * dropZoneSpacer | ||
override func layoutDropZones() { | ||
guard let unwrappedDropZoneB = dropZoneB else { | ||
fatalError("No dropZoneB provided") | ||
} | ||
|
||
// TODO(@hugo): Add type declaration | ||
Check failure on line 13 in Modules/GameEngineKit/Sources/_NewSystem/Views/DragAndDrop/TwoZones/DragAndDropTwoZonesScene.swift GitHub Actions / lint
|
||
let dropZoneNodeA = SKSpriteNode() | ||
let dropZoneNodeB = SKSpriteNode() | ||
|
||
// TODO(@hugo): Adapt size to final images given by the Design team | ||
Check failure on line 17 in Modules/GameEngineKit/Sources/_NewSystem/Views/DragAndDrop/TwoZones/DragAndDropTwoZonesScene.swift GitHub Actions / lint
|
||
let dropZoneSize = CGSize(width: 280, height: 280) | ||
dropZoneNodeA.size = dropZoneSize | ||
dropZoneNodeB.size = dropZoneSize | ||
|
||
dropZoneNodeA.texture = SKTexture(imageNamed: dropZoneA.details.value) | ||
dropZoneNodeB.texture = SKTexture(imageNamed: unwrappedDropZoneB.details.value) | ||
|
||
let dropZonePosition = size.width / 4 | ||
dropZoneNodeA.position = CGPoint(x: dropZonePosition, y: dropZoneSize.height / 2) | ||
dropZoneNodeB.position = CGPoint(x: dropZonePosition * 3, y: dropZoneSize.height / 2) | ||
|
||
dropZoneNodeA.name = dropZoneA.details.value | ||
dropZoneNodeB.name = unwrappedDropZoneB.details.value | ||
addChild(dropZoneNodeA) | ||
addChild(dropZoneNodeB) | ||
|
||
dropZoneA.node = dropZoneNodeA | ||
dropZoneB?.node = dropZoneNodeB | ||
} | ||
} |