作者:18岁的淡淡淡色彩 | 来源:互联网 | 2023-05-18 00:37
Iamafairlynewprogrammer,attemptingtomakeitsothatduringabrickedbreakerlikegame,when
I am a fairly new programmer, attempting to make it so that during a bricked breaker like game, when the ball hits the paddle, I would like to add one point to the score. I think I am partway there, but cannot figure it out.
我是一个相当新的程序员,试图在像游戏这样的断球游戏中,当球碰到球拍时,我想在分数上加一分。我想我是在那里,但我想不明白。
let BallCategory : UInt32 = 0x1 <<0 //
let BottomCategory : UInt32 = 0x1 <<1 //
let BlockCategory : UInt32 = 0x1 <<2 //
let PaddleCategory : UInt32 = 0x1 <<3 //
bottom.physicsBody?.categoryBitMask = BottomCategory
bottom.physicsBody?.cOntactTestBitMask= BallCategory
paddle.physicsBody?.categoryBitMask = PaddleCategory
paddle.physicsBody?.cOntactTestBitMask= BallCategory
paddle.physicsBody?.collisiOnBitMask= BallCategory
ball.physicsBody?.categoryBitMask = BallCategory
ball.physicsBody?.cOntactTestBitMask= BottomCategory | PaddleCategory
ball.physicsBody?.cOntactTestBitMask= PaddleCategory
var score = 0
func didBeginContact(contact: SKPhysicsContact) {
score = +1
}
let label = SKLabelNode(fontNamed: "Chalkduster")
label.text = String(score)
label.fOntSize= 50
label.fOntColor= SKColor.whiteColor()
label.position = CGPoint (x: 568, y: 600)
addChild(label)
These are three sections of my code I believe I need to change in order to have the score work in my game and if you could help me, I would appreciate it.
这是我的代码的三个部分,我相信我需要改变,以便在我的游戏中获得分数,如果你能帮助我,我会很感激。
1 个解决方案