实现子弹自动向前运动 定时器 移动精灵 精灵释放
2011-07-18 20:55
351 查看
#import "cocos2d.h"#import "Bullet.h"
@implementation Bullet////-(id) init//{// self = [super init];// if (self)// {// self = [CCSprite spriteWithFile:@"0001.png"];// //;// }// return self;//}//
-(void)start1{ //定时期设定 [self schedule:@selector(up) interval:1/20.0];}//自己运行-(void )up{ CGFloat x; x= self.position.x; //NSLog(@"%f",self.position.y); // int y=self.position.y +10; self.position = ccp(x, y); if (y> 480) {//自动把精灵释放 [self removeFromParentAndCleanup:YES]; } }
-(void)dealloc { [super dealloc];}@end
@implementation Bullet////-(id) init//{// self = [super init];// if (self)// {// self = [CCSprite spriteWithFile:@"0001.png"];// //;// }// return self;//}//
-(void)start1{ //定时期设定 [self schedule:@selector(up) interval:1/20.0];}//自己运行-(void )up{ CGFloat x; x= self.position.x; //NSLog(@"%f",self.position.y); // int y=self.position.y +10; self.position = ccp(x, y); if (y> 480) {//自动把精灵释放 [self removeFromParentAndCleanup:YES]; } }
-(void)dealloc { [super dealloc];}@end
相关文章推荐
- cocos2d-x学习笔记(三)让精灵按照自己设定的运动轨迹行动(曲线移动)。(以椭圆轨迹为例)。
- 关于移动设备自动挂载的实现
- 第二天2-1,2,3,4】【自动扩展】【添加数据文件】【创建表空间】【undo表空间】【修改用户默认表空间】【释放没用的空间|移动表到新的表空间】
- 完美主义:实现iOS输入框自动移动
- cocos2dx扩展CCAction实现精灵抛物线运动
- cocos2d-x 如何使用CCProgressTimer作为血条,实现跟随怪物进行移动,自动掉血,然后死亡。
- TiledMapEditor创建地图,精灵在地图上下左右移动,尚未实现碰撞检测功能
- 动态分配资源的自动释放 – auto_ptr的实现原理
- cocos2dx扩展CCAction实现精灵抛物线运动
- 仿真树叶飘落效果的实现(精灵旋转、翻转、钟摆运动等综合运用)
- 动态分配资源的自动释放 – auto_ptr的实现原理
- Servlet监听器与Timer定时器配合实现JAVA WEB应用简单自动作业
- 自定义控件实现广告头自动移动,viewpager的运用,和自己利用xml画图,自定义圆点,构造选择器的方法
- SMP3.0学习笔记之八 使用Kapsel Update插件实现移动应用的自动更新
- JavaScript代码实现左右上下自动晃动自动移动
- JTable选择一行,输入数字,自动向前移动一位,点击退格键,删除最后一个数字
- cocos2d-x学习笔记(三)让精灵按照自己设定的运动轨迹行动(曲线移动)。(以椭圆轨迹为例)。
- js实现相对定位div块移动_自动排列
- 网页在移动设备上实现自动缩放
- [转]单例模式——C++实现自动释放单例类的实例