我想用Arial字体创建一个标签.我尝试2路,但都声明已弃用.创建标签的好方法是什么?
Label::create("Hello World", "Arial", 32); //declared deprecated
LabelTTF::create("Hello World", "Arial", 32); //declared deprecated
Run Code Online (Sandbox Code Playgroud) 我使用以下代码定期生成SKNodes.有没有办法使这些SKNode的生成周期随机.具体来说,如何使下面的代码中的"delayFish"成为一个随机延迟的动作?
[self removeActionForKey:@"fishSpawn"];
SKAction* spawnFish = [SKAction performSelector:@selector(spawnLittleFishes) onTarget:self];
SKAction* delayFish = [SKAction waitForDuration:3.0/_moving.speed];
SKAction* spawnThenDelayFish = [SKAction sequence:@[spawnFish, delayFish]];
SKAction* spawnThenDelayFishForever = [SKAction repeatActionForever:spawnThenDelayFish];
[self runAction:spawnThenDelayFishForever withKey:@"fishSpawn"];
Run Code Online (Sandbox Code Playgroud) 在这里,我正在优化我的sprite-kit代码,试图测试我的游戏引擎的界限.
使用仪器时间分析我修复了我自己的大部分问题,现在是唯一的瓶颈
37.0ms 66.0% 0,0 -[SKTextureAtlas textureNamed:]
Run Code Online (Sandbox Code Playgroud)
(我的游戏每半秒从TextureAtlases加载很多精灵)奇怪的是,似乎在我的大多数测试中,似乎纯粹的NSString比较名称导致上面三分之一以上的工作方法.子树:
15.0ms 26.7% 0,0 -[NSString caseInsensitiveCompare:]
15.0ms 26.7% 0,0 -[NSString compare:options:range:]
15.0ms 26.7% 0,0 -[NSString compare:options:range:locale:]
15.0ms 26.7% 6,0 CFStringCompareWithOptionsAndLocale
Run Code Online (Sandbox Code Playgroud)
对于性能如此重要的东西,苹果提供的字符串比较真的很糟糕吗?为什么它们不能提供更简单的方法来访问地图集中的纹理,我们这里不需要花哨的字符串,它可以通过int迭代我们所关心的.
有这方面的比较经验吗?
我正在尝试通过代码快速创建文本字段,这是我的代码片段:
let hiddenTextField = UITextField(frame: CGRectMake(0, self.size.height - 30, 50, 10))
hiddenTextField.borderStyle = UITextBorderStyleRoundedRect
Run Code Online (Sandbox Code Playgroud)
问题是-我收到此错误:
使用未解析的标识符'UITextBorderStyleRoundedRect'
注意:我正在SKScene的子类中执行此操作
有什么线索吗?
我对类方法调用有一个Swift noobie问题.我正在为我的孩子们使用Sprite Kit构建一个简单的学习应用程序.我在GameScene中定义了一个全局变量scoreCount,我几乎完成了所有游戏逻辑,例如检测正确答案和增加scoreCount.我也有GameOverScene.在两者上我都显示了分数 - 标签.我使用scoreCount参数(在GameScene中)保持得分.但是,由于我对Swift和Sprite Kit很陌生,我想知道如何在GameViewController中更新乐谱标签?所以基本上我想从GameScene调用GameViewController.updateLabels().
我知道这不是理想的方式,但请分享您的解决方案概念.谢谢!
我的问题的意思是,例如,当我向左移动鼠标时,如何使您的播放器自动旋转,并且我的整个角色身体将旋转并将其旋转限制回 2D 视图。
如果你们知道的话,类似于“Rochard”游戏。但我很难弄清楚。
这是我的代码:
#pragma strict
var spinx : int = 0;
var spiny : int = 0;
var spinz : int = 0;
function Update () {
transform.Rotate(spinx, spiny, spinz);
}
Run Code Online (Sandbox Code Playgroud) 我尝试启动应用程序时出现此错误.我的应用程序应该只是一个空的SKScene.根据我的理解,这通常是由于没有导入适当的框架.我已经连接了我的UIKit和SpriteKit框架,这些是我正在使用的唯一两个框架.
以下是我的ViewController代码:
import UIKit
import SpriteKit
class GameViewController: UIViewController {
var scene: GameScene!
override func viewDidLoad() {
super.viewDidLoad()
// Configure the view
let skView = view as SKView
skView.multipleTouchEnabled = false
//Create and configure the scene
scene = GameScene(size: skView.bounds.size)
scene.scaleMode = .AspectFill
// Present the scene.
skView.presentScene(scene)
}
override func prefersStatusBarHidden() -> Bool {
return true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Release any cached data, images, etc that aren't in use.
}
}
Run Code Online (Sandbox Code Playgroud)
以下是我的GameScene代码:
import UIKit
import …Run Code Online (Sandbox Code Playgroud) 我有这个plist文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<key>levels</key>
<array>
<dict>
<key>x</key>
<int>80</int>
<key>y</key>
<int>266</int>
</dict>
<dict>
<key>x</key>
<int>170</int>
<key>y</key>
<int>266</int>
</dict>
</array>
</plist>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用cocos2dx v3.2读取该文件:
ValueMap data;
std::string path = FileUtils::getInstance()->fullPathForFilename("my.plist");
data = FileUtils::getInstance()->getValueMapFromFile(path);
auto arrLevels = data.at("levels").asValueVector();
for(int i = 0; i < arrLevels.capacity(); i++){
//I don't know what I have to do here to get the x value and y value of the current item.
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮我吗?我正在所有互联网中搜索,为此发现的所有示例均不足。
如果我在SKScene中有一个SKSpriteNode:
let sprite = SKSpriteNode(imageNamed:"Spaceship")
champion.position = CGPointMake(self.size.width/2, self.size.height/2)
champion.setScale(0.25)
self.addChild(champion)
Run Code Online (Sandbox Code Playgroud)
现在,将这个节点添加到场景中之后,我想在将鼠标移到该节点上时更改其颜色。
如何检测此节点上的鼠标悬停,以便可以更改其颜色?
我在SKSpriteNode类中看到一个mouseEntered事件。我会用吗?如何射击?
还是应该使用其他方法?
Assets/Scripts/ThirdPersonCamera.cs(3,7):错误CS0246:找不到类型或命名空间名称"UnityEditor".您是否缺少using指令或程序集引用?
我很困惑为什么我得到这个错误.....
为什么会这样?
sprite-kit ×6
swift ×4
ios ×3
cocos2d-x ×2
skscene ×2
c# ×1
c++ ×1
function ×1
global ×1
label ×1
macos ×1
optimization ×1
performance ×1
plist ×1
random ×1
rotation ×1
skaction ×1
sknode ×1
skspritenode ×1
uitextfield ×1
unityscript ×1