Node in swift not appearing

和自甴很熟 提交于 2020-01-15 09:32:08

问题


I'm trying to put a node in my game on Swift, but it's not appearing. Please help!

import SpriteKit
import GameplayKit

class GameScene: SKScene {


    override func didMove(to view: SKView) {

        let levelLabelNode = SKLabelNode(fontNamed: "Arial")
        levelLabelNode.text = "Level"
        levelLabelNode.fontSize = 30
        levelLabelNode.fontColor = SKColor.white
        levelLabelNode.position = CGPoint(x: self.frame.size.width/2, y: self.frame.size.height*0.75)
        self.addChild(levelLabelNode)

here's the code


回答1:


I copied the same code I also faced the same problem coz the font color is white its match with background color.if you have changed the font's color then you can able to see the label in the screen

let levelLabelNode = SKLabelNode(fontNamed: "Arial")
        levelLabelNode.text = "Level"
        levelLabelNode.fontSize = 30
        levelLabelNode.fontColor = SKColor.green
        levelLabelNode.position = CGPoint(x: self.frame.size.width/2, y: self.frame.size.height*0.75)
        self.addChild(levelLabelNode)



来源:https://stackoverflow.com/questions/41557068/node-in-swift-not-appearing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!