当前位置: 编程技术>移动开发
本页文章导读:
▪应用plist创建精灵并执行动画 使用plist创建精灵并执行动画 素材图:
然后使用Texture Packer放到一张图片上,并生成plist文件
接下来直接上代码
CCSize size = CCDirector::sharedDirector()->getWinSize(); //获得屏幕的尺寸
.........
▪ ScrollView indicators 一直展示 ScrollView indicators 一直显示
需要自己设置一个tag
#define noDisableVerticalScrollTag 836913
#define noDisableHorizontalScrollTag 836914
@implementation UIImageView (ForScrollView)
- (void) setAlpha:(float)alpha {
if (self.su.........
▪ 施用崩溃信息汇报并重新启动应用 应用崩溃信息汇报并重新启动应用
1.拦截UncaughtExceptionApplication.onCreate()是整个Android应用的入口方法。在该方法中执行如下代码即可拦截UncaughtException:ueHandler = new UEHandler(this); // 设置异常处.........
[1]应用plist创建精灵并执行动画
来源: 互联网 发布时间: 2014-02-18
使用plist创建精灵并执行动画
素材图:
然后使用Texture Packer放到一张图片上,并生成plist文件
接下来直接上代码
CCSize size = CCDirector::sharedDirector()->getWinSize(); //获得屏幕的尺寸
CCArray* pArray = CCArray::createWithCapacity(4);
CCSpriteFrameCache* pCache = CCSpriteFrameCache::sharedSpriteFrameCache(); //获得SpriteFrame的缓存
pCache->addSpriteFramesWithFile("attack.plist");
CCSprite* pSprite = CCSprite::createWithSpriteFrameName("A1_0.png"); //用attack.png中的第一张图片创建一个精灵
pSprite->setPosition(ccp(size.width/2,size.height/2)); //设置精灵的坐标
char name[20];
for(int i=0; i<4; i++) //将plist中的图片都加载,放到array中
{
sprintf(name, "A1_%d.png", i);
CCSpriteFrame* pframe = pCache->spriteFrameByName(name);
pArray->addObject(pframe);
}
CCAnimation* pAnimation = CCAnimation::createWithSpriteFrames(pArray,0.2f); //用array中的spriteframe创建一个animation,每帧间隔0.2s
CCAnimate* panimate = CCAnimate::create(pAnimation);
pSprite->runAction(CCRepeatForever::create(panimate));运行结果就是
在mac下面qq截图不能截动态的,就给个样子,大家自己写个demo试试就可以看到效果。
[2] ScrollView indicators 一直展示
来源: 互联网 发布时间: 2014-02-18
ScrollView indicators 一直显示
需要自己设置一个tag
#define noDisableVerticalScrollTag 836913
#define noDisableHorizontalScrollTag 836914
@implementation UIImageView (ForScrollView)
- (void) setAlpha:(float)alpha {
if (self.superview.tag == noDisableVerticalScrollTag) {
if (alpha == 0 && self.autoresizingMask == UIViewAutoresizingFlexibleLeftMargin) {
if (self.frame.size.width < 10 && self.frame.size.height > self.frame.size.width) {
UIScrollView *sc = (UIScrollView*)self.superview;
if (sc.frame.size.height < sc.contentSize.height) {
return;
}
}
}
}
if (self.superview.tag == noDisableHorizontalScrollTag) {
if (alpha == 0 && self.autoresizingMask == UIViewAutoresizingFlexibleTopMargin) {
if (self.frame.size.height < 10 && self.frame.size.height < self.frame.size.width) {
UIScrollView *sc = (UIScrollView*)self.superview;
if (sc.frame.size.width < sc.contentSize.width) {
return;
}
}
}
}
[super setAlpha:alpha];
}
@end
[3] 施用崩溃信息汇报并重新启动应用
来源: 互联网 发布时间: 2014-02-18
应用崩溃信息汇报并重新启动应用
1.拦截UncaughtException
Application.onCreate()是整个Android应用的入口方法。在该方法中执行如下代码即可拦截UncaughtException:
ueHandler = new UEHandler(this);
// 设置异常处理实例
Thread.setDefaultUncaughtExceptionHandler(ueHandler);
2.抓取导致程序崩溃的异常信息
UEHandler是Thread.UncaughtExceptionHandler的实现类
重写uncaughtException方法,在方法里可以获得异常,比且自己增加跳转。
3.程序抛异常后,要关闭整个应用
这样做 可以有效地防止出现不友好的bug,同时回馈到开发者手里。
1.拦截UncaughtException
Application.onCreate()是整个Android应用的入口方法。在该方法中执行如下代码即可拦截UncaughtException:
ueHandler = new UEHandler(this);
// 设置异常处理实例
Thread.setDefaultUncaughtExceptionHandler(ueHandler);
2.抓取导致程序崩溃的异常信息
UEHandler是Thread.UncaughtExceptionHandler的实现类
重写uncaughtException方法,在方法里可以获得异常,比且自己增加跳转。
3.程序抛异常后,要关闭整个应用
这样做 可以有效地防止出现不友好的bug,同时回馈到开发者手里。
1 楼
Sassoon
2013-03-20
可以有效地防止出现不友好的bug
最新技术文章: