Nic*_*arr 7 objective-c rotation sprite-kit
我想使用Sprite Kit制作一个基于文本的游戏(那些学习打字游戏).
我以为我会使用SKLabelNode作为字符串,但是当我尝试设置anchorPoint以便旋转它时,我得到一个错误,即SKLabelNode没有anchorPoint属性:
SKLabelNode *hello = [SKLabelNode labelNodeWithFontNamed:@"Courier-Bold"];
hello.text = @"Hello,";
//this throws an error:
hello.anchorPoint = CGPointMake(0.5,1.0);
Run Code Online (Sandbox Code Playgroud)
什么是好的解决方法?我如何垂直定位我的文本字符串,同时使用physicsBody将它们视为物理对象?
Use*_*234 13
SKLabelNode没有锚点.
使用verticalAlignmentMode属性垂直对齐SKLabelNode.
SKLabelVerticalAlignmentModeBaseline
Run Code Online (Sandbox Code Playgroud)
定位文本,使字体的基线位于节点的原点上.
SKLabelVerticalAlignmentModeCenter
Run Code Online (Sandbox Code Playgroud)
将文本垂直居中于节点的原点.
SKLabelVerticalAlignmentModeTop
Run Code Online (Sandbox Code Playgroud)
定位文本,使文本顶部位于节点的原点上.
SKLabelVerticalAlignmentModeBottom
Run Code Online (Sandbox Code Playgroud)
定位文本,使文本的底部位于节点的原点上.
最后,我意识到我根本不需要anchorPoint来实现我想要实现的 \xe2\x80\x94 相反,我使用
\n\nhello.zRotation = M_PI/2;\nRun Code Online (Sandbox Code Playgroud)\n\n这适用于 SKLabelNode。
\n| 归档时间: |
|
| 查看次数: |
6072 次 |
| 最近记录: |