屏蔽方法:
进入新的CCLayer时:
[[CCDirector sharedDirector].touchDispatcher addTargetedDelegate:self priority:kCCMenuHandlerPriority swallowsTouches:YES];
离开此CCLayer时调用
[[CCDirector sharedDirector].touchDispatcher removeDelegate:self];
重写方法
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event;
解释:
由于CCMenu 按钮接受按键的优先级为-128(值越小优先级越高),所有不论处在那一层都会接收到点击
[[CCDirector sharedDirector].touchDispatcher addTargetedDelegate:self priority:kCCMenuHandlerPriority swallowsTouches:YES];
priority: 优先级 kCCMenuHandlerPriority(-128)
swallowsToucher: 是否吃掉按钮不叫其他层再接收了 如果为NO其他层还是一样会接收到Touch数据
注意离开此CCLayer时一定要调用
[[CCDirector sharedDirector].touchDispatcher removeDelegate:self];
否则下面层将不再接收按键
posted @
2012-10-20 12:07 CrackRen 阅读(680) |
评论 (0) |
编辑 收藏
Class FileUtils
此类包含了一般的通用文件操作工具。
● 读、写文件
● 创建一个目录,如果其上级的各级父目录不存在,也会创建它们
● 拷贝文件和目录
● 删除文件和目录
● 将URL转换成文件
● 通过过滤器或者扩展名列出文件
● 比较文件内容
● 修改文件最后修改日期
● 计算校验和
累了,去读意优休息一下下,QQ空间,美文,非主流,网络日记,搞笑短信,祝福短信,热门短信,有意思啊
Class IOUtils
此类包含了一般的IO流操作工具。
● closeQuietly – 忽略 nulls和错误而关闭一个流
● toXxx/read – 这些类从一个流读取数据
● write – 这些方法写数据到一个流
● copy – 这些方法从一个流到另一个流拷贝数据
● contentEquals – 这些方法比较两个流的数据
Class FilenameUtils
此类包含了文件和路径的操作工具。
当你将在Windows下开发的Java程序转移到Unix系统时,你可能遇到文件路径的问题,这个类的目标帮你解决这个问题。注意: 你完全可以不用这个类,而使用JDK提供的两个构造参数的File类,File(File,String)。
大多数方法识别两个分隔符(/ 和 \), 和两个前缀集合。
这个类奖一个文件名称定义成六部分(例如 C:\dev\project\file.txt):
● 前缀 – C:\
● 路径 – dev\project\
● 全路径 – C:\dev\project\
● 文件名称 – file.txt
● 基本名称 – file
● 扩展名 – txt
这个类能够处理以分隔符结尾的目录文件。如果你忽略了最后一个分隔符,它也能识别其是文件还是目录。这个类仅支持UNIX和Windows样式的名称,前缀匹配方式如下:
Windows:
a\b\c.txt –> "" –> 相对
\a\b\c.txt –> "\" –> 当前的绝对驱动器
C:a\b\c.txt –> "C:" –> 相对的驱动器
C:\a\b\c.txt –> "C:\" –> 绝对
\\server\a\b\c.txt –> "\\server\" –> UNC
Unix:
a/b/c.txt –> "" –> 相对
/a/b/c.txt –> "/" –> 绝对
~/a/b/c.txt –> "~/" –> 当前用户
~ –> "~/" –> 当前用户 (slash added)
~user/a/b/c.txt –> "~user/" –> 命名用户
~user –> "~user/" –> 命名用户 (slash added)
org.apache.commons.io.filefilter
此包中包含了大量的文件名称过滤器。
DirectoryFilter 仅接受目录
PrefixFileFilter 基于前缀
SuffixFileFilter 基于后缀
NameFileFilter 基于文件名称
WildcardFileFilter 基于通配符
AgeFileFilter 基于最后修改时间
SizeFileFilter 基于文件尺寸
下载地址:
http://commons.apache.org/io/
posted @
2012-10-20 12:06 CrackRen 阅读(274) |
评论 (0) |
编辑 收藏
当使用JSplitpane分隔面板时
可以通过 splitPaneMain.setOneTouchExpandable(true);
设置 oneTouchExpandable 属性的值,要使 JSplitPane 在分隔条上提供一个 UI 小部件来快速展开/折叠分隔条
但是如果要初始化时默认就折叠一边的话 网上搜索添加下面几句就可以了,但是验证了下只有在一边没加控件时才行
// Hide left or top
splitPaneMain.getLeftComponent().setMinimumSize(new Dimension());
splitPaneMain.setDividerLocation(0.0d);
// Hide right or bottom
splitPaneMain.getRightComponent().setMinimumSize(new Dimension());
splitPaneMain.setDividerLocation(1.0d);
posted @
2011-11-24 12:02 CrackRen 阅读(437) |
评论 (0) |
编辑 收藏
写个工具把不同文件夹下的文件拷贝到一个文件夹下去,碰到格问题,需要考虑到生成唯一文件名,想来想去还是使用MD5计算吧
import java.security.MessageDigest;
/**
*
* @author apple
*/
public class xMD5 {
public final static String MD5(String s) {
char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F'};
try {
byte[] strTemp = s.getBytes();
//使用MD5创建MessageDigest对象
MessageDigest mdTemp = MessageDigest.getInstance("MD5");
mdTemp.update(strTemp);
byte[] md = mdTemp.digest();
int j = md.length;
char str[] = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
byte b = md[i];
//将没个数(int)b进行双字节加密
str[k++] = hexDigits[b >> 4 & 0xf];
str[k++] = hexDigits[b & 0xf];
}
return new String(str);
} catch (Exception e) {
return null;
}
}
}
posted @
2011-10-25 17:37 CrackRen 阅读(183) |
评论 (0) |
编辑 收藏
// 触摸屏
-(void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
for( UITouch *touch in touches ) {
CGPoint location = [touch locationInView: [touch view]];
location = [[CCDirector sharedDirector] convertToGL: location];
// 各种动作
// 瞬时动作
// 设置坐标
id action0 = [CCPlace actionWithPosition:ccp(240,160)];
// 隐藏
id action1 = [CCHide action];
// 显示
id action2 = [CCShow action];
// 隐藏/显示
id action3 = [CCToggleVisibility action];
// 延时动作
// 移动
id action4 = [CCMoveTo actionWithDuration:2 position:ccp(0,0)];
id action5 = [CCMoveBy actionWithDuration:2 position:ccp(100,100)];
// 弹跳
id action6 = [CCJumpTo actionWithDuration:2 position:ccp(0,200) height:30 jumps:5];
id action7 = [CCJumpBy actionWithDuration:2 position:ccp(100, 0) height:30 jumps:5];
// 贝塞尔移动
ccBezierConfig bezier;
bezier.controlPoint_1 = ccp(0, 0);
bezier.controlPoint_2 = ccp(100, 300);
bezier.endPosition = ccp(0,100);
id action8 = [CCBezierTo actionWithDuration:3 bezier:bezier];
id action9 = [CCBezierBy actionWithDuration:3 bezier:bezier];
// 缩放
id action10 = [CCScaleTo actionWithDuration:2 scale:4];
id action11 = [CCScaleBy actionWithDuration:2 scale:0.5];
// 旋转
id action12 = [CCRotateTo actionWithDuration:2 angle:180];
id action13 = [CCRotateBy actionWithDuration:2 angle:-180];
// 闪烁
id action14 = [CCBlink actionWithDuration:3 blinks:5];
// 色调变化
id action15 = [CCTintTo actionWithDuration:2 red:255 green:0 blue:0];
id action16 = [CCTintBy actionWithDuration:0.5 red:0 green:255 blue:255];
// 淡化到/淡入/淡出
id action17 = [CCFadeTo actionWithDuration: 1 opacity:80];
id action18 = [CCFadeIn actionWithDuration:1.0f];
id action19 = [CCFadeOut actionWithDuration:1.0f];
// 动画顺序播放
CCAnimation *animation = [CCAnimation animation];
[animation setDelay:2];
// 这里就添加两帧,需要自己添加
[animation addFrameWithTexture:sprTest.texture rect:CGRectMake(0, 0, 44, 34)];
[animation addFrameWithTexture:sprTest.texture rect:CGRectMake(0, 34, 44, 34)];
id action20 = [CCAnimate actionWithAnimation: animation];
// 组合动作
// 动画序列
id action21 = [CCSequence actions:action19, action18, nil];
// 重复动作
id action22 = [CCRepeat actionWithAction:action21 times:10];
// 延时动作
id action23 = [CCDelayTime actionWithDuration:1];
// 同时动作
id action24 = [CCSpawn actions:action0, action4, action21, nil];
// 无限循环动作
id action25 = [CCRepeatForever actionWithAction:action21];
// 扩展动作
// 回调动作
id acf0 = [CCCallFunc actionWithTarget:self selector:@selector(CallBack1)];
// 回调动作,传递动画自身指针
id acf1 = [CCCallFuncN actionWithTarget:self selector:@selector(CallBack2:)];
// 回调动作,传递动画自身指针已经一个参数
id acf2 = [CCCallFuncND actionWithTarget:self selector:@selector(CallBack3:data:) data:(void*)2];
id action26 = [CCSequence actions:action19, action18, acf0, action23, action0, nil];
// 反转动作,只能用在有方向有顺序的动作上
id action27 = [action9 reverse];
// 速度变化
//id ac = [CCSequence actions:action9,action27,nil];
id actiontest = [CCMoveBy actionWithDuration:0.5 position:ccp(200,0)];
id ac = [CCSequence actions:actiontest,actiontest, nil];
// 渐快
id action28 = [CCEaseIn actionWithAction:ac rate:3];
// 渐慢
id action29 = [CCEaseOut actionWithAction:ac rate:3];
// 先渐快再渐慢
id action30 = [CCEaseInOut actionWithAction:ac rate:3];
// 正弦波移动
id action31 = [CCEaseSineIn actionWithAction:ac];
id action32 = [CCEaseSineOut actionWithAction:ac];
id action33 = [CCEaseSineInOut actionWithAction:ac];
// 由极慢至极快
id action34 = [CCEaseExponentialIn actionWithAction:ac];
// 由极快到极慢
id action35 = [CCEaseExponentialOut actionWithAction:ac];
// 由极慢至极快 再由极快到慢
id action36 = [CCEaseExponentialInOut actionWithAction:ac];
// 手动设定速度,可通过SetSpeed不断调整
id action37 = [CCSpeed actionWithAction:ac speed:(CCRANDOM_0_1() * 5)];
[sprTest runAction:action37];
}
}
// 回调函数1
- (void) CallBack1
{
[sprTest runAction:[CCTintBy actionWithDuration:2 red:255 green:0 blue:255]];
}
// 回调函数2
- (void) CallBack2:(id)sender
{
[sender runAction:[CCTintBy actionWithDuration:1 red:255 green:0 blue:255]];
}
// 回调函数3
-(void) CallBack3:(id)sender data:(void*)data
{
[sender runAction:[CCTintBy actionWithDuration:(NSInteger)data red:255 green:0 blue:255]];
}
posted @
2011-10-14 13:18 CrackRen 阅读(945) |
评论 (0) |
编辑 收藏
//
-(void) startMenu:(id) sender
{
CCScene* scenec = [CCTestScene scene];
//部落格------
//CCTransitionTurnOffTiles *transitionScene = [CCTransitionTurnOffTiles transitionWithDuration:3 scene:scenec];
//近远-远近-----
//CCTransitionShrinkGrow *transitionScene = [CCTransitionShrinkGrow transitionWithDuration:3 scene:scenec];
//另一个layout左侧进入(视觉感觉是屏幕右移)
//CCTransitionSlideInL *transitionScene = [CCTransitionSlideInL transitionWithDuration:3 scene:scenec];
//另一个layout右侧进入(视觉感觉是屏幕左移)
//CCTransitionSlideInR *transitionScene = [CCTransitionSlideInR transitionWithDuration:3 scene:scenec];
//另一个layout上侧进入(视觉感觉是屏幕下移)
//CCTransitionSlideInT *transitionScene = [CCTransitionSlideInT transitionWithDuration:3 scene:scenec];
//另一个layout下侧进入(视觉感觉是屏幕上移)
//CCTransitionSlideInB *transitionScene = [CCTransitionSlideInB transitionWithDuration:3 scene:scenec];
//当前屏幕被分为3列,两则下移,中间上移
//CCTransitionSplitCols *transitionScene = [CCTransitionSplitCols transitionWithDuration:3 scene:scenec];
//当前屏幕被分为3列,两则左移,中间右移
//CCTransitionSplitRows *transitionScene = [CCTransitionSplitRows transitionWithDuration:3 scene:scenec];
//扇形转换-----
//CCTransitionRadialCW *transitionScene = [CCTransitionRadialCW transitionWithDuration:3 scene:scenec];
//平面旋转-----
//CCTransitionRotoZoom *transitionScene = [CCTransitionRotoZoom transitionWithDuration:3 scene:scenec];
//近-远-跳动------
//CCTransitionJumpZoom *transitionScene = [CCTransitionJumpZoom transitionWithDuration:3 scene:scenec];
//立体反转(X轴)--(还有种从近到远,从远到近的感觉)--------
//CCTransitionZoomFlipX *transitionScene = [CCTransitionZoomFlipX transitionWithDuration:3 scene:scenec];
//立体反转(Y轴)-(还有种从近到远,从远到近的感觉)-------
//CCTransitionZoomFlipY *transitionScene = [CCTransitionZoomFlipY transitionWithDuration:3 scene:scenec];
//立体反转(X,Y轴)---(还有种从近到远,从远到近的感觉)-----
//CCTransitionZoomFlipAngular *transitionScene = [CCTransitionZoomFlipAngular transitionWithDuration:3 scene:scenec];
//另外一个layout左侧进入覆盖当前layout
//CCTransitionMoveInL *transitionScene = [CCTransitionMoveInL transitionWithDuration:3 scene:scenec];
//另外一个layout右侧进入覆盖当前layout
//CCTransitionMoveInR *transitionScene = [CCTransitionMoveInR transitionWithDuration:3 scene:scenec];
//另外一个layout上侧进入覆盖当前layout
//CCTransitionMoveInT *transitionScene = [CCTransitionMoveInT transitionWithDuration:3 scene:scenec];
//另外一个layout下侧进入覆盖当前layout
//CCTransitionMoveInB *transitionScene = [CCTransitionMoveInB transitionWithDuration:3 scene:scenec];
//立体反转(X轴)--2D平面反转,没有远近感
//CCTransitionFlipX *transitionScene = [CCTransitionFlipX transitionWithDuration:3 scene:scenec];
//立体反转(Y轴)--2D平面反转,没有远近感
//CCTransitionFlipY *transitionScene = [CCTransitionFlipY transitionWithDuration:3 scene:scenec];
//立体反转(X,Y轴)--2D平面反转,没有远近感
//CCTransitionFlipAngular *transitionScene = [CCTransitionFlipAngular transitionWithDuration:3 scene:scenec];
//实体-透明-实体(默认无颜色,可以附带颜色)
//CCTransitionFade* transitionScene = [CCTransitionFade transitionWithDuration:3 scene:scenec withColor:ccWHITE];
//另外一个直接渐变覆盖当前layout
//CCTransitionCrossFade *transitionScene = [CCTransitionCrossFade transitionWithDuration:3 scene:scenec];
//移动(方格状)部落格,从左下往右上
//CCTransitionFadeTR *transitionScene = [CCTransitionFadeTR transitionWithDuration:3 scene:scenec];
//移动(方格状)部落格,从右上往左下
CCTransitionFadeBL *transitionScene = [CCTransitionFadeBL transitionWithDuration:3 scene:scenec];
//移动(长矩形,宽度是屏幕宽)部落格,从下往上
//CCTransitionFadeUp *transitionScene = [CCTransitionFadeUp transitionWithDuration:3 scene:scenec];
//移动(长矩形,宽度是屏幕宽)部落格,从上往下
//CCTransitionFadeDown *transitionScene = [CCTransitionFadeDown transitionWithDuration:3 scene:scenec];
[[CCDirector sharedDirector] replaceScene: transitionScene];
}
posted @
2011-10-11 13:57 CrackRen 阅读(270) |
评论 (0) |
编辑 收藏
BOOL Download( CString szURL, CString szDstFile )
{
BOOL res = false;
CInternetSession Session;
CHttpFile *pHttpFile = NULL;
try{
pHttpFile = (CHttpFile*)Session.OpenURL(szURL);
}catch(CInternetException * m_pException){
pHttpFile = NULL;
m_pException->m_dwError;
m_pException->Delete();
Session.Close();
res = false;
}
CString strLine;
CFile xmlFile;
BOOL bResult = xmlFile.Open(szDstFile, CFile::modeCreate | CFile::modeWrite);
if(pHttpFile != NULL && bResult)
{
while(pHttpFile->ReadString(strLine) != NULL)
{
xmlFile.Write(strLine, strLine.GetLength());
}
xmlFile.Close();
res = true;
}
else
{
res = false;
}
Session.Close();
pHttpFile->Close();
delete pHttpFile;
pHttpFile = NULL;
return res;
}
posted @
2011-08-31 16:35 CrackRen 阅读(131) |
评论 (0) |
编辑 收藏