i am new to ios development. i am learning to develop a game using this youtube tutorial.
I want the ground image to be on the bottom of the screen. I can manually give some values and bring it to bottom. But i want it to detect the frame size and get the values for X and Y.
Currently it looks like this.
import SpriteKit
import GameplayKit
class GameScene: SKScene {
var Ground = SKSpriteNode()
override func didMove(to view: SKView) {
Ground = SKSpriteNode(imageNamed: "Ground")
Ground.setScale(0.5)
Ground.position = CGPoint(x:self.frame.width/2, y: 0 + Ground.frame.height/2)
self.addChild(Ground)
}
override func update(_ currentTime: TimeInterval) {
// Called before each frame is rendered
}
}
can some one help me to bring the ground image to bottom.
You can use
minX
,minY
,midX
,midY
,maxX
andmaxY
of aCGRect
to get the actual values of those positions.So in your case you could write:
and your ground image should be...grounded...(sorry :))
Hope that helps you.