/*
* ZJoystick: http://zaldzbugz.posterous.com/first-article
*
* Copyright (c) 2011-2013 Zaldy Bernabe N. Bughaw
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#import "cocos2d.h"
typedef enum {
kJLowerLeft,
kLowerRight,
}tJoystickPlacement;
typedef enum {
kFirstQuadrant,
kSecondQuadrant,
kThirdQuadrant,
kFourthQuadrant,
}tControlQuadrant;
@protocol ZJoystickDelegate<NSObject>
@optional
-(void)joystickControlBegan;
-(void)joystickControlMoved;
-(void)joystickControlEnded;
//version 1.3
-(void)joystickControlDidUpdate:(id)joystick toXSpeedRatio:(CGFloat)xSpeedRatio toYSpeedRatio:(CGFloat)ySpeedRatio;
@end
#define kJoystickRadius 50.0f
#define kControlActionInterval 0.2f
@interface ZJoystick : CCSprite {
CCTexture2D *_normalTexture; //background normal (container)
CCTexture2D *_selectedTexture; //background selected (container)
NSString *_controllerSpriteFile; //controller sprite sfile
tControlQuadrant _controlQuadrant; //quadrant where your controller is
CCSprite *_controller; //controller sprite
BOOL isCurrentlyControlling; //check if we touched inside the container
BOOL _isJostickDisabled; //Check if joystick is enabled
BOOL _isControlling; //check if joystick is currently controlling
id <ZJoystickDelegate> _delegate; //delegate
CGFloat _controllerActualDistance; //actual distance of controller relative to background and container
CGFloat _speedRatio; //speed ratio for each joysitkc controller movement
CGPoint _controllerActualPoint; //controller actual point relative to background
id _controlledObject; //the object the controller is controlling
//version 1.2
CGFloat _joystickRadius;
int _joystickTag;
}
@property(nonatomic, retain) CCTexture2D *normalTexture;
@property(nonatomic, retain) CCTexture2D *selectedTexture;
@property(nonatomic, retain) NSString *controllerSpriteFile;
@property(nonatomic, assign) BOOL isControlling;
@property(nonatomic, assign) BOOL isJostickDisabled;
@property(nonatomic, assign) CCSprite *controller;
@property(nonatomic, assign) tControlQuadrant controlQuadrant;
@property(nonatomic, retain) id <ZJoystickDelegate> delegate;
@property(nonatomic, assign) CGFloat controllerActualDistance;
@property(nonatomic, assign) CGFloat speedRatio;
@property(nonatomic, assign) CGPoint controllerActualPoint;
@property(nonatomic, retain) id controlledObject;
//version 1.2
@property(nonatomic, assign) CGFloat joystickRadius;
@property(nonatomic, assign) int joystickTag;
-(CGRect) getBoundingRect;
-(CGFloat)getYMinimumLimit;
-(CGFloat)getYMaximumLimit;
-(CGFloat)getXMinimumLimit;
-(CGFloat)getXMaximumLimit;
+(id)joystickNormalSpriteFile:(NSString *)filename1
selectedSpriteFile:(NSString *)filename2
controllerSpriteFile:(NSString *)controllerSprite;
-(void)deactivateScheduler;;
@end
没有合适的资源?快使用搜索试试~ 我知道了~
Cocos2d添加ZJoystick遥控杆所需源文件和图片
共9个文件
png:6个
m:1个
h:1个
5星 · 超过95%的资源 需积分: 10 24 下载量 104 浏览量
2014-04-10
11:28:18
上传
评论
收藏 136KB ZIP 举报
温馨提示
Cocos2d添加ZJoystick遥控杆所需源文件和图片 cocos2d学习之路四(添加遥控杆)所需资源
资源推荐
资源详情
资源评论
收起资源包目录
ZJoustick.zip (9个子文件)
ZJoustick
JoystickContainer_norm-hd.png 44KB
JoystickContainer_trans.png 14KB
ZJoystick.m 16KB
JoystickContainer_norm.png 15KB
Joystick_norm.png 2KB
JoystickContainer_trans-hd.png 38KB
Joystick_norm-hd.png 10KB
ZJoystick.h 4KB
.DS_Store 6KB
共 9 条
- 1
资源评论
- anqier20142014-04-12非常不错,很实用谢谢了
- 嗨_土豆2014-04-11第一次下载,确实不错!
- soul432337522019-06-09非常实用,多谢了
- autodesker2020-02-11资源不错,能用。
LvesLi
- 粉丝: 81
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功