【问题标题】:Getting the location of a section of a sprite获取精灵一部分的位置
【发布时间】:2013-06-22 22:08:25
【问题描述】:

下面的代码创建一个精灵并分配锚点和旋转。精灵会旋转很多,有没有办法获得精灵右下角的位置。就像,精灵锚点是(0,1),我可以获得锚点(1,1)的位置点吗?这样即使精灵在旋转,我也总能得到相同的位置?

tempsprite = [CCSprite spriteWithSpriteFrameName:@"image.png"];
tempsprite.rotation += 90;
tempsprite.anchorPoint = ccp(0,1);
tempsprite.position = tempsprite;
[self addChild:tempsprite];

【问题讨论】:

    标签: iphone ios objective-c cocoa-touch cocos2d-iphone


    【解决方案1】:

    好的,所以我想办法以防万一有人遇到与我类似的问题。

    int length = 100;
    int offset = 50
    
    CGFloat angle = ([self findangle]+offset) * M_PI/180;
    CGPoint startpoint1 = startingpoint;
    CGPoint endPoint1 =
    CGPointMake( startpoint1.x + ( sinf( angle ) * length ), startpoint1.y + ( cosf( angle ) * length ) );
    
    
    return endPoint1;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多