I found an image with 2 faces, up and down (imagery of a card). This image changes when you tap the image.
I used bool
to get the expression, however, once again the scene is presented, I want to show the image which was above / below in the previous scene. Note that this is only 1 scene, and it presents itself again.
How can I pass a Bool
value between the scenes?
// Update:
My code:
.... var FaceUp = true .... override funk komovatview (see: sqview ) {Titikesr = Skeccr (image named "Tiseediar png") TTexture.filteringMode = .Nearest T2Texture = SKTexture (imageNamed: "T2Card.png") T2Texture.filteringMode = .Nearest card = SKSpriteNode (texture: TTexture) Card.position = CGPoint (X: Rate.position.x - (TransparentLayer.size.width / 3), y: rate.position.y) Card.size = CGSize (width: 50, height: 50) card.name = "card" card .zPosition = 100 self.addChild (card) Flip (FaceUp)} Flipp (State: Boole) {Fasup = State if (! State) {Card.texture = TTexture // Ruti Pleyrktekstek = T1 Pleyrkrn action (Rnanimeshn 1) Face-Up = true} and {Kardktekst = T2Texture // error Pleyrkteksteks = T2 Pleyrkrn action (Rnanimeshn 2) Faceup = false}} override function touchesBegan (touches: NSSet, withEvent event: UIEvent) {to touch: UITouch = go UITouch as touches.anyObject () touchLocation = touch.locationInNode (self) to the node: SKNode = self.nodeAtPoint (touchLocation) If node .name == "card" {scale 1 = sakayction. ScaleTo (0.7, duration: 0.1) Repeat = SKAction.scaleTo (1, duration: 0.1) scaling = SKAction.sequence Switch to ([Scale 1, Scale 2]) Card.runAction (scaling) self.flip (faceup)}} restart () {self.saveHighScore () LastScore = function score self.addLeaderboardScore (self.Score) to transition = SKTransition .fadeWithDuration (1.8) to view = GameScene (size: self.frame.size) Scene.LastScore = score Scene.FaceUp = faceup scene .scaleMode = SKSceneScaleMode.AspectFill self.scene .view .presentScene (visual, transition ?? Transition)}
You can define GameScene
A function is like the following.
func setCardState (State: Bool) {FaceUp = State if (! State) {Card.texture = Texture2 Player} Texture = T2} Other {Card.actactation = Texture 1 Player.ctactation = T1}}
and call it in the new code with didMoveToView
.
override function didMoveToView (See: SKView) {TTexture = SKTexture (imageNamed: "TCard.png") TTexture.filteringMode = .Nearest T2Texture = SKTexture (imageNamed: "T2Card.png") T2Texture .filteringMode =. Closest Card = SKSpriteNode (Texture: TteExctions) Card.position = CGPoint (x: rate.position.x - (transparent. Size.width / 3), y: rate correction. I) Card.size = CGSize (width: 50, height: 50) Card.name = "card" card.geosition = 100 auto.addChild (card) setcardstate (faceup) // Added line. }
Set the old face-up
value with restart the
function restart
.
Start the function () {self.saveHighScore () LastScore = Score go to self.addLeaderboardScore (self.Score) Transitions = SKTransition.fadeWithDuration (1.8) Go Scenes = GameScene (Size: self. Frame.size) Scene.LastScore = Score view? .scaleMode = SKSceneScaleMode.AccpectFill Scene.FaceUp = FaceUp // Changed Line Self.scene ?. View? .Prustussin (scene, transit: transition)}
No comments:
Post a Comment