
setContentSize做我想要的.不幸的是,图像移动到内容大小的左下角.设置anchorpoint会移动内容大小,但图像保留在左下角.
CcmenuItem* pickEasy = [CcmenuItemImage itemFromnormalimage:@"radiobutton_off.png" selectedImage:@"radiobutton_on.png" target:self selector:@selector(pickEasyTapped:)]; pickEasy.position = ccp(ss.wIDth * 0.40,ss.height * 0.78); [pickEasy setContentSize:CGSizeMake(50,50)];
提前致谢.
您需要覆盖rectInPixels方法- (CGRect)rectInPixels{CGSize s = [self contentSize];return CGRectMake(0,s.wIDth,s.height);}- (BOol)containstouchLocation:(UItouch *)touch{ CGPoint p = [self converttouchToNodeSpace:touch];CGRect r = [self rectInPixels];return CGRectContainsPoint(r,p);}- (BOol)cctouchBegan:(UItouch *)touch withEvent:(UIEvent *)event {NSSet *alltouches = [event alltouches];for (UItouch *atouch in alltouches) { if ( ![self containstouchLocation:atouch] ) return NO;}return YES;} 这只是告诉精灵检查你改变的CGRect中的触摸lyes
编辑显示CCSprite子类—
- (voID)onEnter{[[CCtouchdispatcher shareddispatcher] addTargetedDelegate:self priority:0 swallowstouches:YES];[super onEnter];}- (voID)onExit{[[CCtouchdispatcher shareddispatcher] removeDelegate:self];[super onExit];} 总结 以上是内存溢出为你收集整理的cocos2d从按钮扩展触摸区域全部内容,希望文章能够帮你解决cocos2d从按钮扩展触摸区域所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)