我有两个标签,在玩家输了时添加;但是,重新启动游戏时,仍有1个标签。我没有看到任何可能意外复制标签的代码。
添加标签:
func getScores(x: SKScene) {
//HighScore
if currentScore > highScore
{
Defaults.setInteger(currentScore, forKey: "High Score")
//High Score Particles
//highScoreParticle()
}
//High Score
highScoreLabel = UILabel(frame: CGRect(x: x.frame.midX - 100 , y: x.frame.midY + 70, width: 200, height: 50))
highScoreLabel.textAlignment = NSTextAlignment.Center
highScoreLabel.text = "HighScore: \(Defaults.valueForKey("High Score")!)"
highScoreLabel.font = UIFont(name: "Helvetica Neue UltraLight", size: 30)
highScoreLabel.textColor = UIColor.whiteColor()
x.view?.addSubview(highScoreLabel)
//Current Score
currentScoreLabel = UILabel(frame: CGRect(x: x.frame.midX - 50 , y: x.frame.midY, width: 100, height: 50))
currentScoreLabel.textAlignment = NSTextAlignment.Center
currentScoreLabel.text = "Score: \(currentScore)"
currentScoreLabel.font = UIFont(name: "Helvetica Neue UltraLight", size: 30)
currentScoreLabel.textColor = UIColor.whiteColor()
x.view?.addSubview(currentScoreLabel)
}
删除标签:
func resetGame(scene: SKScene) {
//Removes Labels
startLabel.removeFromSuperview()
currentScoreLabel.removeFromSuperview()
highScoreLabel.removeFromSuperview()
//Remove everything off scene
scene.removeAllChildren()
scene.removeAllActions()
//Reset Variables
currentScore = 0
}
highScoreLabel
不会从场景中删除
答案 0 :(得分:0)
您正在向场景视图控制器添加UILabel。现场无法控制。您需要创建一个SKLabelNode,然后使用DynamicProvider<ContactForm> provider = new DynamicProviderImpl<ContactForm>(new RecordCredential(csk, aci));
Query<ContactForm> query = provider.createQuery(contactFormModel);
query.setOffset(0).setCount(1);
try {
RecordResults<ContactForm> list = query.add(Conditions.like("namef", "ProBusiness%")).list();
System.out.println("list = " + list.getFastReturnedSize());
if (list.getFastReturnedSize() > 0) {
System.out.println("Contact Name = " + list.getRecords().get(0).getName());
System.out.println("Contact Comments = " + list.getRecords().get(0).getComments());
}
} catch (DynamicloudProviderException e) {
log.error("Error", e);
}