My game will have a lot of AtlasSprites with several AtlasSpriteManagers, and I sort of want to try out TouchDispatcher for the purpose of controlling the AtlasSprites.
Does touchdispatcher work with AtlasSprite ?
A fast, easy to use, free, and community supported 2D game engine
My game will have a lot of AtlasSprites with several AtlasSpriteManagers, and I sort of want to try out TouchDispatcher for the purpose of controlling the AtlasSprites.
Does touchdispatcher work with AtlasSprite ?
In short yes it does, in fact I have a thread in the forum right now asking a question about it.
It appears that when using an unmodified sprite (scale, width, height, all the same) that only the very centre of the sprite is 'touchable'.
Hmmmmmm
Does that mean if I have a large AtlasSprite image, it will only be recognized when the very center (a small portion of the image) is touched ??
In my tests with larger AtlasSprite it appears the top right quadrant (from the centre to the top right) is touchable.
The other three quadrants are not. I used the blocks.png in the tests as an example.
Are you sure its not because its recognizing the center as the "(0,0)" coordinate of the image ?? Which could make the program think that the image's (0,0) coordinate (the bottom left point), is the center of the image, thus only making the upper right corner touchable ?
Perhaps in your code that does the CGRect-recognize stuff ?
I am new, so I might be wrong. If not, am I stuck with creating my own touch control mechanic for my atlasSprites ??
I'm not sure if Rect is the problem though. It's true from what I read that ContentSize will not return a rescaled Sprite but the original Texture2D sprite size.
But even if I keep the Sprite original size, it still is only touch sensitive to the top right hand quadrant. This is with AtlasSprite and regular Sprite.
Hmmmmm
So should I just use texture2d like they do in the pingpong example with the paddles ??
Would this drastically reduce the performance compared to atlassprites ?
bsharp42, can you post your rect method?
As jbhewitt said, that may be the problem, but we won't know until we see it.
I had a similar problem the very first time I tried adding the touch manager. I could only get a touch response from the top-right quadrant. It was because my rect was (0,0,50,100). I changed it to (-25, -50, 50, 100), and it was fine.
I don't have any code yet, cjl.
I was asking a general question whether touch dispatcher worked with AtlasSprites because my new project will be using a lot of Sprites.
I wanted to test out the touch Dispatcher and was wondering if it could be used with AtlasSprites since the demo only used it with texture2D Node.....
I guess I'll just try it out myself later tonight.
Ok I'm not sure what's wrong here. I'm working with the TouchDispatcher test and created a new class that uses AtlasSprite instead of Texture2D called Box. Comparing the paddle to the box here is what i get...
I'm using this method for both classes
- (CGRect)rect
{
CGSize s = self.contentSize;
NSLog(@"box width: %d height:%d", s.height, s.width);
return CGRectMake(-s.width / 2, -s.height / 2, s.width, s.height);
}
the logger shows the following:
paddle width: 0 height:1078984704
box width: 0 height:1081999360
Now both AtlasSprite and Texture2D are loading the same file, but I'm calling AtlasSprite with the CGRectMake option
AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(0,0,width,height) spriteManager:mgr];
width and height are both 64.
The top right handside quadrant is still only touchable. :((((
Ok so I figured out I was using the wrong thing with NSLog and using an int instead of float call... so the real information is...
box width: 480.000000 height:320.000000
paddle width: 64.000000 height:64.000000
Clearly the Box atlassprite is returning the layer size not the atlassprite size...
Anyhow I don't even think that's the problem now.
I've been messing around with the Texture2D side. I've been able to set scaleX and scaleY with it.
[self setScaleX:width];
when the Scale is changed for texture2d, and leaving the rect method the same, the touch stuff still works. Even if I blow it up 3 times, and change the aspect ratio the touch will still work with a clearly broken rect reporting back the width and height as the original texture size.
You must log in to post.