Ios cocos2d 3.x CCButton设置精灵帧图像扭曲和回调/块不工作
我需要设置一个按钮的精灵框架 当我使用构造函数时,它正在工作:Ios cocos2d 3.x CCButton设置精灵帧图像扭曲和回调/块不工作,ios,iphone,cocos2d-iphone,Ios,Iphone,Cocos2d Iphone,我需要设置一个按钮的精灵框架 当我使用构造函数时,它正在工作: CCSprite *sprite = [CCSprite spriteWithImageNamed:@"but.png"]; CCButton *button = [CCButton buttonWithTitle:@"" spriteFrame:sprite.spriteFrame]; [button setBlock:^(id sender){...}] 但是当我以后需要设置精灵框架时 CCB
CCSprite *sprite = [CCSprite spriteWithImageNamed:@"but.png"];
CCButton *button = [CCButton buttonWithTitle:@"" spriteFrame:sprite.spriteFrame];
[button setBlock:^(id sender){...}]
但是当我以后需要设置精灵框架时
CCButton *button = [CCButton buttonWithTitle:@""];
button.background.spriteFrame = sprite.spriteFrame;
还是这个
[button setBackgroundSpriteFrame:sprite.spriteFrame forState:CCControlStateNormal];
两者都不起作用,结果是图像失真,并且不调用回调函数或块
你好,我也遇到了同样的问题,找到了解决办法。就这样做吧:
CCSpriteFrame *spriteFrame = [CCSpriteFrame frameWithImageNamed:@"Icon-Small.png"];
button = [CCButton buttonWithTitle:@"" spriteFrame:spriteFrame];
工作起来很有魅力