Ready to use on screen Joysticks and Buttons for iOS gaming. It's pretty solid. Give it a try! As featured in multiple Apress books about iPhone and iPad 2D Game Development
The autoCenter=NO; is not working because you have created new location variable in side the if condition, which is not available outside the if condition. So for any value of autoCenter the location is CGRectZero
An event/callback system. Events for certain directions/forces/states. Callbacks for events such as start/finish input, etc. Feel free to elaborate on your own needs. :)
When tapping a button, there are times the button will register 2-3 times.
Ex.
-(void) tick:(float)delta {
if (button.active == YES) {
NSLog(@"Tap");
}
}
Click the SneakyButton "Button" will cause the log to display "Tap" 2-3 times. Not sure if it's a bug or I'm implementing the class wrong.
For a fix I add "button.active = NO;" in the if statement.
They don't belong together. Simple as that. I'd rather have two small, neat classes, than one big ugly one. Should've never let them join forces in the first place, but oh well.
Unfortunately SneakyInput fails badly with Cocos2d V2.0 and above dying with the following error:
2012-01-30 10:00:50.864 OpenSpace[588:1be03] +[CCTouchDispatcher addTargetedDelegate:priority:swallowsTouches:]: unrecognized selector sent to class 0xfed9c
2012-01-30 10:00:50.881 OpenSpace[588:1be03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[CCTouchDispatcher addTargetedDelegate:priority:swallowsTouches:]: unrecognized selector sent to class 0xfed9c'
Currently, if you switch from a joystick to a dpad, or vice versa, the deadzones aren't correctly enabled/disabled.
The fix I'm writing right now will automatically enable a deadzone of 10 when changing from a joystick to a dpad. When changing back from dpad to joystick, the deadzone will stay as it is, meaning you must manually disable/reconfigure the deadzone.