【问题标题】:how to chage the height of sprite without changing the value of original of sprite in iphone?如何在不改变iphone中精灵原始值的情况下改变精灵的高度?
【发布时间】:2013-06-24 14:00:17
【问题描述】:
CGRect rect = CGRectMake(sprites.boundingBox.origin.x, sprites.boundingBox.origin.y, sprites.boundingBox.size.width, scale);

如何将此 CGRect 分配给 CCSprite?

    float scale = sprites.boundingBox.size.height * 1.2;
    CGPoint point = CGPointMake(sprites.position.x,sprites.position.y + ((scale -   sprites.boundingBox.size.height) / 2));
    sprites.position = point;
    [self resizeSprite:sprites toWidth:sprites.boundingBox.size.width toHeight:scale];
    -(void)resizeSprite:(CCSprite*)sprite toWidth:(float)width toHeight:(float)height
    {
        sprite.scaleX = width / sprite.contentSize.width;
        sprite.scaleY = height / sprite.contentSize.height;
    }

如何在向上的方向设置高度的动画

【问题讨论】:

    标签: iphone ios objective-c cocos2d-iphone


    【解决方案1】:

    您可以更改比例属性。 scaleX 会改变宽度,scaleY 会改变高度,scale 会同时改变两者:

    sprite.scaleX = 1.1f;
    sprite.scaleY = 0.5f;
    

    【讨论】:

    • 它缩放一次然后我再次触摸它的值而不改变我将它的值存储在数组中并且每次触摸精灵时更新
    猜你喜欢
    • 1970-01-01
    • 2018-08-20
    • 1970-01-01
    • 1970-01-01
    • 2018-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多