Skip to content

Commit

Permalink
♻️ (GameEngineKit): Add overlay on wrong DnD answers
Browse files Browse the repository at this point in the history
  • Loading branch information
HPezz committed Nov 2, 2023
1 parent 34636f8 commit 71de82e
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class DragAndDropBaseScene: SKScene {

func wrongAnswerBehavior(_ node: DraggableImageAnswerNode) {
snapBack(node)
disableWrongAnswer(node)
}

func onDragAnimation(_ node: SKSpriteNode) {
Expand Down Expand Up @@ -198,6 +199,14 @@ class DragAndDropBaseScene: SKScene {
}
}

private func disableWrongAnswer(_ node: DraggableImageAnswerNode) {
let gameplayChoiceModel = viewModel.choices.first(where: { $0.choice.value == node.name })!
if gameplayChoiceModel.choice.dropZone == nil {
node.colorBlendFactor = 0.4
node.isDraggable = false
}
}

override func didMove(to view: SKView) {
self.reset()
}
Expand Down

0 comments on commit 71de82e

Please sign in to comment.