@slipster216 I would like to see the code too if you wouldn't mind sending it to me..
dean at callida dot com
Thanks
A fast, easy to use, free, and community supported 2D game engine
@slipster216 I would like to see the code too if you wouldn't mind sending it to me..
dean at callida dot com
Thanks
It sounds like we really really need a contrib dir or similar for cocos2d, so you don't have to keep emailing this out all the time!
@slipster216
Can you Email me the code too? I would like to see it!
thomas <at> equatior <dot> com
Thank you very much!
Is the Joystick a singleton? Seems like from a design standpoint it could be even though it does have state? I guess that's a personal design decision.
I'd like to view the code also ... please email to greg.heidorn <at> gmail <dot> com.
Thanks!
No, it's not a singleton, because you can have multiple joysticks on screen and it needs to hold state for each one. I'm going to submit a version of this to the trunk soon under an extra's folder.
Ok, it's in the trunk under an extra's folder, along with my proximity manager. Hopefully riq doesn't mind as I think these don't belong as core cocos things, but are obviously very useful.
Thanks for the commit. The proximity manager also seems pretty sweet, I like the simple cache idea as well, could come in useful for a future project were planning.
Thanks!
@slipster216: ok.
I am getting build errors trying to port my game to the 0.9 alpha release. The last 2 errors are in Joystick.h. from the extra's directory.
Any help would be appreciated.
-------
/Joystick.m: In function '-[Joystick touchesBegan:withEvent:]':
/Joystick.m:43: warning: 'CCDirector' may not respond to '-convertCoordinate:'
/Joystick.m:43: warning: (Messages without a matching method signature
/Joystick.m:43: warning: will be assumed to return 'id' and accept
/Joystick.m:43: warning: '...' as arguments.)
/Joystick.m:43: error: invalid initializer
/Joystick.m: In function '-[Joystick touchesMoved:withEvent:]':
/Joystick.m:67: warning: 'CCDirector' may not respond to '-convertCoordinate:'
/Joystick.m:67: error: incompatible types in assignment
-------
Hi,
I'm too an ultra noob and would like a little bit of help implementing the joystick controls. I have got the latest code from the SVN repository for Joystick and have successfully built it. However i'm having problems initialising the Joystick. I have only one joystick in the game to control a Ball. I found some code on a forum relating to this that initialises the mStick like this :
mStick = [[[Joystick alloc] init:0 y:0 w:320 h:480] retain];
If I put this in the (id)init{... I get 'mStick' undeclared.
I'm having trouble as to where I should put this in the code, Should it be in the Ball Layer? and whereabouts in the code.
The code I used following this to detect touches is in the BallLayer.m code as follows but each of the mStick references give compilation errors 'mstick' undeclared.
-(bool)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[mStick touchesBegan:touches withEvent:event];
return kEventHandled;
}
-(bool)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[mStick touchesMoved:touches withEvent:event];
return kEventHandled;
}
-(bool)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[mStick touchesEnded:touches withEvent:event];
return kEventHandled;
}
Think im finding the transition form Java to XCode harder than anticipated.
Any help much appreciated.
Just like Java, you have to declare the type of variable. Therefore, Joystick *mStick = [[[Joystick alloc] init:0 y:0 w:320 h:480] retain]; unless you previously declared Joystick *mStick.
Hi Thanks, I now get the following warning's when I try to compile.
mStickLeft = [[[Joystick alloc] init:0 y:0 w:320 h:480] retain]; WARNING - No '-init:y:w:h:' method found
[layer addChild:mStickLeft z:3]; - WARNING 'Incompatible Objective-C types 'struct Joystick *' expect 'struct CocosNode *' when passing argument 1 of addChild:z' from distinct Objective-C type.
Can anyone help?
The functionality of the joystick when using staticCenter was incomplete; the velocity upon initialization was not (0,0) and the joystick did not reset after touchesEnded. To fix this I changed -(void)setStaticCenter to:
-(void)setStaticCenter:(float)x y:(float)y
{
staticCenterPoint = CGPointMake(x, y);
center = staticCenterPoint;
curPosition = staticCenterPoint;
staticCenter = YES;
}
And also -(bool)touchesEnded to:
-(bool)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if (!active) return NO;
NSArray *allTouches = [touches allObjects];
for (UITouch* t in allTouches) {
if ((int)t == touchAddress) {
active = NO;
if (!staticCenter) {
center = CGPointMake(0,0);
curPosition = CGPointMake(0,0);
}
else if (staticCenter) {
center = staticCenterPoint;
curPosition = staticCenterPoint;
}
return YES;
}
}
return NO;
}
Also, must add this in the interface declarations
CGPoint staticCenterPoint;
You must log in to post.