Skip to content
This repository has been archived by the owner on May 5, 2020. It is now read-only.

Commit

Permalink
Clipboard stars now blink according to right/wrong matches. Changed t…
Browse files Browse the repository at this point in the history
…iles moving speed.
  • Loading branch information
identity2 committed Jul 28, 2017
1 parent 594b4cd commit ce97927
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "clipboard green.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "clipboard green-1.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "clipboard green-2.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "clipboard red-1.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "clipboard red.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "clipboard red-2.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 19 additions & 3 deletions Powerup/VocabMatchingGameScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class VocabMatchingGameScene: SKScene {
]

// MARK: Constants
let timeForTileToReachClipboard = 12.0
let timeForTileToReachClipboard = 6.0
let totalRounds = 5
let tilesPerRound = 2
let timeBetweenTileSpawns = 2.5
let timeBetweenTileSpawns = 2.0

// Sizing and position of the nodes (They are relative to the width and height of the game scene.)
// Score Box
Expand Down Expand Up @@ -70,6 +70,8 @@ class VocabMatchingGameScene: SKScene {
// Textures
let tileTexture = SKTexture(imageNamed: "vocabmatching_tile")
let clipboardTexture = SKTexture(imageNamed: "vocabmatching_clipboard")
let clipboardCorrectTexture = SKTexture(imageNamed: "vocabmatching_clipboard_green")
let clipboardWrongTexture = SKTexture(imageNamed: "vocabmatching_clipboard_red")

// Layers (zPosition)
let backgroundLayer = CGFloat(-0.1)
Expand All @@ -96,6 +98,7 @@ class VocabMatchingGameScene: SKScene {
// Animations
let swappingAnimationDuration = 0.2
let endSceneFadeInAnimationDuration = 0.5
let clipboardStarBlinkAnimationDuration = 0.3

// Strings
let endSceneTitleLabelText = "Game Over"
Expand Down Expand Up @@ -322,10 +325,23 @@ class VocabMatchingGameScene: SKScene {
// Check if the tile and the clipboard matches. If so, increment score. Then start the next round.
func checkIfMatches(tile: VocabMatchingTile) {
let tileLane = tile.laneNumber
if tile.matchingID == clipboards[tileLane].matchingID {
let clipboardAtLane = clipboards[tileLane]
if tile.matchingID == clipboardAtLane.matchingID {
// Is a match. Increment score.
score += 1
scoreLabel.text = String(score)

// Blink the star of the clipboard to green.
clipboardAtLane.texture = clipboardCorrectTexture
clipboardAtLane.run(SKAction.wait(forDuration: clipboardStarBlinkAnimationDuration)) {
clipboardAtLane.texture = self.clipboardTexture
}
} else {
// Not a match, blink the star of the clipboard to red.
clipboardAtLane.texture = clipboardWrongTexture
clipboardAtLane.run(SKAction.wait(forDuration: clipboardStarBlinkAnimationDuration)) {
clipboardAtLane.texture = self.clipboardTexture
}
}

// Remove the current tile.
Expand Down

0 comments on commit ce97927

Please sign in to comment.