问题描述
||
是否可以在Spritesheet中更改框架的CGRect?我的问题是我有两个按钮,但是我按了设备上的按钮,但它们并非总是(我想该术语正在注册)在iPhone中注册。我当时以为是因为我使用的是\“ CGRectContainsPoint(leftB.boundingBox,touchLocation))\”并且图像有点小。
谢谢
解决方法
UITouch * touch = [触摸anyObject];
location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
暂停= [CCSprite spriteWithFile:@ \“ pause.png \”];
pause.position = ccp(25,65);
[self addChild:pause];
CGRect pauseRect = CGRectMake([暂停位置] .x-[暂停contentSize] .width,
[暂停位置] .y-[暂停contentSize] .height,
3 * [pause contentSize] .height,3 * [pause contentSize] .width);
如果(CGRectContainsPoint(pauseRect,location)){
NSLog(@ \“已检测到您的触摸!\”);
}
,作为一种解决方案,您可以通过点击创建一个小的精灵来检查与按钮的交集。
CGRectIntersectsRect()