小编Sur*_*slu的帖子

14
推荐指数
1
解决办法
5656
查看次数

为什么SKSpriteNode node.frame.size.width小于node.size.width?

为什么SKSpriteNode node.frame.size.width小于node.size.width?
这是示例代码,可能您需要插入自己的图像

- (void)DrawRect:(SKSpriteNode *)node
{
SKShapeNode *rect = [[SKShapeNode alloc] init];

CGMutablePathRef myPath = CGPathCreateMutable();
CGPathAddRect(myPath, nil, node.frame);
rect.path = myPath;
rect.lineWidth = 1;

rect.strokeColor = [SKColor whiteColor];
rect.glowWidth = 0;
[self addChild:rect];
}
Run Code Online (Sandbox Code Playgroud)

//这里绘制精灵

-(void) DrawSpriteNode
{
SKTextureAtlas *atlas = [SKTextureAtlas atlasNamed:@"character"];
SKSpriteNode* node = (SKSpriteNode *)[SKSpriteNode spriteNodeWithTexture:[atlas         textureNamed:@"testimage.png"]];

node.position = CGPointMake(self.anchorPoint.x, self.anchorPoint.y);
NSLog(@"node frame width x :%f",node.frame.size.width);
NSLog(@"node frame height y :%f",node.frame.size.height);
NSLog(@"node width y :%f",node.size.width);
NSLog(@"node height y :%f",node.size.height);

node.anchorPoint = CGPointMake(0.5, 0.5);
[self DrawRect: …
Run Code Online (Sandbox Code Playgroud)

ios sprite-kit skspritenode

6
推荐指数
1
解决办法
6101
查看次数

KnockOut Mapping Hierarchical JS对象

我正在尝试使用KnockOut映射插件创建视图模型,

这是对象,基本上下面是一个带有单词的句子.

var data = {
name: 'Example Title',
sentences: [
    {id: 1, words: [{text: 'word1'}, {text: 'word2'}]},
    {id: 2, words: [{text: 'word3'}, {text: 'word4'}]}
           ]};
Run Code Online (Sandbox Code Playgroud)

我想有三个视图模型,

文章应包含句子,句子应包含文字

var ArticleViewModel = function(data) 
{
  var self = this;
  self.id = ko.observable(data.id);
  self.sentences = ko.observableArray([]);
}

var SentenceViewModel = function(data) 
{
  var self = this;
  self.id = ko.observable(data.id);
  self.words = ko.observableArray([]);
}

var WordViewModel = function(data) 
{
  var self = this;
  self.id = ko.observable(data.id);
  self.text = ko.observable(data.text);
}
Run Code Online (Sandbox Code Playgroud)

我想把它放在View中,如下所示;

<p data-bind="foreach:sentences">
  <span …
Run Code Online (Sandbox Code Playgroud)

knockout-mapping-plugin knockout-2.0 knockout.js

3
推荐指数
1
解决办法
3425
查看次数