zoukankan      html  css  js  c++  java
  • [一位菜鸟的COCOS-2D编程之路]精灵表单的制作以及简易动画的生成

    1.第一步:使用Zwoptex 制作精灵表单


    2.制作的表单的名称为 cocos2Dpng,cocos2D.plist;

    3.精灵的动画效果 主要分为五部分。

    // on "init" you need to initialize your instance
    -(id) init
    {
    	// always call "super" init
    	// Apple recommends to re-assign "self" with the "super's" return value
    	if( (self=[super init]) ) {
    		
    		
    
    		// ask director for the window size
    		//
            
            //1将精灵帧纹理添加到精灵帧缓存中
            [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"cocos2D.plist"];
            //2创建一个精灵表单
            CCSpriteBatchNode *batchNode = [CCSpriteBatchNode batchNodeWithFile:@"cocos2D.png"];
            
            [self addChild:batchNode];
            
            //穿件图片帧列表
            NSMutableArray *animFrames = [NSMutableArray array];
            
            for (int i = 1; i < 4; i ++) {
            
                CCSpriteFrame *temp = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"pandawalk%d.png",i]];
                
                [animFrames addObject:temp];
            }
            
            //4创建一个 动画对象
            CCAnimation *walkAnim = [CCAnimation animationWithSpriteFrames:animFrames delay:0.1f];
            //5创建精灵,运行动画动作
            CGSize size = [[CCDirector sharedDirector] winSize];
            CCSprite *panda = [CCSprite spriteWithSpriteFrameName:@"pandawalk1.png"];
            panda.position = ccp(size.width*0.8, size.height*0.4);
            
            id walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:walkAnim]];
            
            [panda runAction:walkAction];
            
            [panda runAction:[CCMoveTo actionWithDuration:6.0f position:ccp(size.width*0.2, size.height*0.4)]];
            
            [batchNode addChild:panda];
            
            
    	
    		
    	}
    	return self;
    }
    


    效果图:


  • 相关阅读:
    使用element-ui的table组件时,渲染为html格式
    vue-quill-editor富文本编辑器,添加了汉化样式却汉化不了
    MySQL版本问题导致的SQLException
    MySQL中 ORDER BY 与 LIMIT 的执行顺序
    MySQL 测试数据批量导入
    CentOS 7 安装 Maven
    CentOS 7 安装 Gradle
    CentOS 7 安装 RabbitMQ
    CentOS 7 安装 Tomcat 8.5.43
    CentOS 7 配置网络
  • 原文地址:https://www.cnblogs.com/fuhaots2009/p/3481649.html
Copyright © 2011-2022 走看看