gpt4 book ai didi

ios - SpriteNode 不可见

转载 作者:行者123 更新时间:2023-11-29 01:06:47 25 4
gpt4 key购买 nike

我正在尝试使用以下方法创建我的用户 SpriteNode。纹理是 Kladde,图像也不为空。

func spawnPlayer() {
if didFirstTap == true && isGameOver == false {
let collisionMask = CollisionCategory.Surrounding.rawValue | CollisionCategory.Platform.rawValue
let x = self.frame.size.width / 4
let y = CGRectGetMidY(self.frame)
let node = SKNode()
node.position = CGPointMake(frame.size.width + playerTexture!.size().width, 0)
playerNode = SKSpriteNode(texture: playerTexture)
playerNode!.setScale(1.0)
playerNode!.position = CGPointMake(x, y)
playerNode!.speed = 1.0
playerNode!.zRotation = 0.0
playerNode!.physicsBody = SKPhysicsBody(circleOfRadius: playerNode!.size.height / 2)
playerNode!.physicsBody?.dynamic = true
playerNode!.physicsBody?.allowsRotation = false
playerNode!.physicsBody?.categoryBitMask = CollisionCategory.Player.rawValue
playerNode!.physicsBody?.contactTestBitMask = collisionMask
playerNode!.physicsBody?.collisionBitMask = collisionMask
playerNode!.physicsBody!.velocity = CGVectorMake( 0, 0 )
node.addChild(playerNode!)
addChild(node)
}
}

我希望有人知道,为什么我的节点是不可见的?

最佳答案

查看节点生成的位置:

node.position = CGPointMake(frame.size.width + playerTexture!.size().width, 0)

然后在此基础上将玩家移动到节点的位置

let x = self.frame.size.width / 4
let y = CGRectGetMidY(self.frame)
playerNode!.position = CGPointMake(x, y)

这个可怜的家伙远远超出了屏幕空间。

关于ios - SpriteNode 不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36271572/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com