Adding new Files for Cancel Button in ModalAttack
This commit is contained in:
parent
df222bba84
commit
5d98027d8a
@ -46,6 +46,8 @@
|
|||||||
AB1D75A0245DEC0500671525 /* MapFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1D759F245DEC0500671525 /* MapFactory.swift */; };
|
AB1D75A0245DEC0500671525 /* MapFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1D759F245DEC0500671525 /* MapFactory.swift */; };
|
||||||
ABA03DA0244BD54F00A66916 /* Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABA03D9F244BD54F00A66916 /* Base.swift */; };
|
ABA03DA0244BD54F00A66916 /* Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABA03D9F244BD54F00A66916 /* Base.swift */; };
|
||||||
AE151589245F18EF001D363E /* MatchmakingHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE151588245F18EF001D363E /* MatchmakingHelper.swift */; };
|
AE151589245F18EF001D363E /* MatchmakingHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE151588245F18EF001D363E /* MatchmakingHelper.swift */; };
|
||||||
|
AEBF3AFF246EB146004F7CD5 /* CancelBtnNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEBF3AFE246EB146004F7CD5 /* CancelBtnNode.swift */; };
|
||||||
|
AEBF3B01246EB187004F7CD5 /* CancelBtnComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEBF3B00246EB187004F7CD5 /* CancelBtnComponent.swift */; };
|
||||||
C04783EE2468583F004961FB /* intro-music.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C04783ED2468583F004961FB /* intro-music.mp3 */; };
|
C04783EE2468583F004961FB /* intro-music.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C04783ED2468583F004961FB /* intro-music.mp3 */; };
|
||||||
C04783F024685995004961FB /* SettingsScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04783EF24685995004961FB /* SettingsScene.swift */; };
|
C04783F024685995004961FB /* SettingsScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04783EF24685995004961FB /* SettingsScene.swift */; };
|
||||||
C05FAED62468559D0006AF2E /* SoundManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C05FAED52468559D0006AF2E /* SoundManager.swift */; };
|
C05FAED62468559D0006AF2E /* SoundManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C05FAED52468559D0006AF2E /* SoundManager.swift */; };
|
||||||
@ -109,6 +111,8 @@
|
|||||||
AB1D759F245DEC0500671525 /* MapFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapFactory.swift; sourceTree = "<group>"; };
|
AB1D759F245DEC0500671525 /* MapFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapFactory.swift; sourceTree = "<group>"; };
|
||||||
ABA03D9F244BD54F00A66916 /* Base.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base.swift; sourceTree = "<group>"; };
|
ABA03D9F244BD54F00A66916 /* Base.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base.swift; sourceTree = "<group>"; };
|
||||||
AE151588245F18EF001D363E /* MatchmakingHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchmakingHelper.swift; sourceTree = "<group>"; };
|
AE151588245F18EF001D363E /* MatchmakingHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchmakingHelper.swift; sourceTree = "<group>"; };
|
||||||
|
AEBF3AFE246EB146004F7CD5 /* CancelBtnNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CancelBtnNode.swift; sourceTree = "<group>"; };
|
||||||
|
AEBF3B00246EB187004F7CD5 /* CancelBtnComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CancelBtnComponent.swift; sourceTree = "<group>"; };
|
||||||
C04783ED2468583F004961FB /* intro-music.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = "intro-music.mp3"; sourceTree = "<group>"; };
|
C04783ED2468583F004961FB /* intro-music.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = "intro-music.mp3"; sourceTree = "<group>"; };
|
||||||
C04783EF24685995004961FB /* SettingsScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsScene.swift; sourceTree = "<group>"; };
|
C04783EF24685995004961FB /* SettingsScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsScene.swift; sourceTree = "<group>"; };
|
||||||
C05FAED52468559D0006AF2E /* SoundManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoundManager.swift; sourceTree = "<group>"; };
|
C05FAED52468559D0006AF2E /* SoundManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoundManager.swift; sourceTree = "<group>"; };
|
||||||
@ -174,6 +178,8 @@
|
|||||||
110360E4244B101B008610AF /* Info.plist */,
|
110360E4244B101B008610AF /* Info.plist */,
|
||||||
AE151588245F18EF001D363E /* MatchmakingHelper.swift */,
|
AE151588245F18EF001D363E /* MatchmakingHelper.swift */,
|
||||||
3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */,
|
3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */,
|
||||||
|
AEBF3B00246EB187004F7CD5 /* CancelBtnComponent.swift */,
|
||||||
|
AEBF3AFE246EB146004F7CD5 /* CancelBtnNode.swift */,
|
||||||
C04783EF24685995004961FB /* SettingsScene.swift */,
|
C04783EF24685995004961FB /* SettingsScene.swift */,
|
||||||
C064E9A7246C0EA50022B228 /* LabelNode.swift */,
|
C064E9A7246C0EA50022B228 /* LabelNode.swift */,
|
||||||
C064E9A9246C114C0022B228 /* LabelComponent.swift */,
|
C064E9A9246C114C0022B228 /* LabelComponent.swift */,
|
||||||
@ -407,6 +413,7 @@
|
|||||||
C064E9A8246C0EA50022B228 /* LabelNode.swift in Sources */,
|
C064E9A8246C0EA50022B228 /* LabelNode.swift in Sources */,
|
||||||
3EBD242C245D8044003CECE7 /* GameCenterHelper.swift in Sources */,
|
3EBD242C245D8044003CECE7 /* GameCenterHelper.swift in Sources */,
|
||||||
AB1D759C245DD18100671525 /* MapProtocol.swift in Sources */,
|
AB1D759C245DD18100671525 /* MapProtocol.swift in Sources */,
|
||||||
|
AEBF3B01246EB187004F7CD5 /* CancelBtnComponent.swift in Sources */,
|
||||||
AB1D75A0245DEC0500671525 /* MapFactory.swift in Sources */,
|
AB1D75A0245DEC0500671525 /* MapFactory.swift in Sources */,
|
||||||
AB1D759D245DD18100671525 /* TwoPlayerDefaultTestMap.swift in Sources */,
|
AB1D759D245DD18100671525 /* TwoPlayerDefaultTestMap.swift in Sources */,
|
||||||
9EBFD7552462CF5A00E1E219 /* SliderComponent.swift in Sources */,
|
9EBFD7552462CF5A00E1E219 /* SliderComponent.swift in Sources */,
|
||||||
@ -415,6 +422,7 @@
|
|||||||
9E174C82245DD81D00209FF0 /* ButtonNode.swift in Sources */,
|
9E174C82245DD81D00209FF0 /* ButtonNode.swift in Sources */,
|
||||||
9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */,
|
9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */,
|
||||||
9E174C84245DD8CE00209FF0 /* Button.swift in Sources */,
|
9E174C84245DD8CE00209FF0 /* Button.swift in Sources */,
|
||||||
|
AEBF3AFF246EB146004F7CD5 /* CancelBtnNode.swift in Sources */,
|
||||||
110360DB244B101A008610AF /* GameViewController.swift in Sources */,
|
110360DB244B101A008610AF /* GameViewController.swift in Sources */,
|
||||||
2086465C2461B66200817C23 /* TimerComponent.swift in Sources */,
|
2086465C2461B66200817C23 /* TimerComponent.swift in Sources */,
|
||||||
110360D3244B101A008610AF /* AppDelegate.swift in Sources */,
|
110360D3244B101A008610AF /* AppDelegate.swift in Sources */,
|
||||||
|
27
GoldWars/GoldWars/CancelBtnComponent.swift
Normal file
27
GoldWars/GoldWars/CancelBtnComponent.swift
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// CancelBtnComponent.swift
|
||||||
|
// GoldWars
|
||||||
|
//
|
||||||
|
// Created by Chauntalle Schüle on 15.05.20.
|
||||||
|
// Copyright © 2020 SP2. All rights reserved.
|
||||||
|
//
|
||||||
|
import GameplayKit
|
||||||
|
import SpriteKit
|
||||||
|
|
||||||
|
class CancelBtnComponent: GKComponent {
|
||||||
|
|
||||||
|
var cancelBtnNode: CancelBtnNode
|
||||||
|
|
||||||
|
init(iconName: String, text: String, position: CGPoint, isEnabled:Bool, onButtonPress: @escaping () -> ()) {
|
||||||
|
cancelBtnNode = CancelBtnNode(iconName: iconName,
|
||||||
|
text: text,
|
||||||
|
isEnabled: isEnabled,
|
||||||
|
position: position,
|
||||||
|
onButtonPress: onButtonPress)
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
}
|
76
GoldWars/GoldWars/CancelBtnNode.swift
Normal file
76
GoldWars/GoldWars/CancelBtnNode.swift
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
//
|
||||||
|
// CancelBtnNode.swift
|
||||||
|
// GoldWars
|
||||||
|
//
|
||||||
|
// Created by Chauntalle Schüle on 15.05.20.
|
||||||
|
// Copyright © 2020 SP2. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SpriteKit
|
||||||
|
|
||||||
|
class CancelBtnNode: SKSpriteNode {
|
||||||
|
|
||||||
|
var isEnabled: Bool{
|
||||||
|
didSet{
|
||||||
|
if isEnabled {
|
||||||
|
self.alpha = 1
|
||||||
|
self.childNode(withName: "label")?.alpha = 1
|
||||||
|
} else {
|
||||||
|
self.alpha = 0.3
|
||||||
|
self.childNode(withName: "label")?.alpha = 0.3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let onButtonPress: () -> ()
|
||||||
|
|
||||||
|
init(iconName: String, text: String, isEnabled: Bool, position: CGPoint, onButtonPress: @escaping () -> ()) {
|
||||||
|
self.onButtonPress = onButtonPress
|
||||||
|
self.isEnabled = isEnabled
|
||||||
|
let texture = SKTexture(imageNamed: "yellow_cross")
|
||||||
|
super.init(texture: texture, color: SKColor.white, size: texture.size())
|
||||||
|
self.position = position
|
||||||
|
|
||||||
|
let label = SKLabelNode(fontNamed: "Courier-Bold")
|
||||||
|
label.fontSize = 30
|
||||||
|
label.fontColor = SKColor.black
|
||||||
|
label.zPosition = 1
|
||||||
|
label.verticalAlignmentMode = .center
|
||||||
|
label.text = text
|
||||||
|
label.name = "label"
|
||||||
|
|
||||||
|
if iconName.isEmpty {
|
||||||
|
label.position = CGPoint(x: 0, y: 0)
|
||||||
|
} else {
|
||||||
|
label.position = CGPoint(x: size.width * 0.25, y: 0)
|
||||||
|
let icon = SKSpriteNode(imageNamed: iconName)
|
||||||
|
icon.position = CGPoint(x: -size.width * 0.25, y: 0)
|
||||||
|
icon.zPosition = 1
|
||||||
|
self.addChild(icon)
|
||||||
|
}
|
||||||
|
self.addChild(label)
|
||||||
|
|
||||||
|
isUserInteractionEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
|
if isEnabled {
|
||||||
|
let action = SKAction.sequence(
|
||||||
|
[
|
||||||
|
SKAction.scale(by: (3/4), duration: 0.3),
|
||||||
|
SKAction.scale(by: (4/3), duration: 0.3),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
self.childNode(withName: "label")?.run(action)
|
||||||
|
self.run(action)
|
||||||
|
onButtonPress()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
required init?(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user