<bdo id='89KCf'></bdo><ul id='89KCf'></ul>

      <i id='89KCf'><tr id='89KCf'><dt id='89KCf'><q id='89KCf'><span id='89KCf'><b id='89KCf'><form id='89KCf'><ins id='89KCf'></ins><ul id='89KCf'></ul><sub id='89KCf'></sub></form><legend id='89KCf'></legend><bdo id='89KCf'><pre id='89KCf'><center id='89KCf'></center></pre></bdo></b><th id='89KCf'></th></span></q></dt></tr></i><div id='89KCf'><tfoot id='89KCf'></tfoot><dl id='89KCf'><fieldset id='89KCf'></fieldset></dl></div>
    1. <legend id='89KCf'><style id='89KCf'><dir id='89KCf'><q id='89KCf'></q></dir></style></legend>

    2. <tfoot id='89KCf'></tfoot>

      1. <small id='89KCf'></small><noframes id='89KCf'>

        iPhone - cocos2d - 动画和 C++ 类

        时间:2024-08-12
          <tbody id='8gdoy'></tbody>
        1. <i id='8gdoy'><tr id='8gdoy'><dt id='8gdoy'><q id='8gdoy'><span id='8gdoy'><b id='8gdoy'><form id='8gdoy'><ins id='8gdoy'></ins><ul id='8gdoy'></ul><sub id='8gdoy'></sub></form><legend id='8gdoy'></legend><bdo id='8gdoy'><pre id='8gdoy'><center id='8gdoy'></center></pre></bdo></b><th id='8gdoy'></th></span></q></dt></tr></i><div id='8gdoy'><tfoot id='8gdoy'></tfoot><dl id='8gdoy'><fieldset id='8gdoy'></fieldset></dl></div>
          <tfoot id='8gdoy'></tfoot>
          • <bdo id='8gdoy'></bdo><ul id='8gdoy'></ul>

              • <small id='8gdoy'></small><noframes id='8gdoy'>

              • <legend id='8gdoy'><style id='8gdoy'><dir id='8gdoy'><q id='8gdoy'></q></dir></style></legend>

                  本文介绍了iPhone - cocos2d - 动画和 C++ 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将动画添加到我的游戏(iPhone 应用,使用 cocos2d).

                  I'm trying to add animations to my game (iPhone app, using cocos2d).

                  游戏是用 C++ 编写的,现在我想在 iPhone 上运行它,所以大部分类都是用 C++ 编写的.

                  The game was written in C++, and now I want to run it on iPhone, so most of the classes are in c++.

                  事情是这样的.我在 init 函数的 obj-c 类中创建 CCSprite,CCAction,然后在 sprite 上运行 CCAction.并且动画正在运行.

                  The thing looks like that. I'm creating CCSprite,CCAction in obj-c class in init function, and then run CCAction on sprite. And animation is working.

                  但是我想把这个 CCSprite 和 CCAction 变量放在我的 C++ 类中.我在初始化类中创建 *CCSprite 并将这个指针发送到 c++ 类.然后,我创建 CCAction 并在 sprite 上运行它.

                  But I want to put this CCSprite and CCAction variables in my C++ class. I create *CCSprite in init class and send this pointer to the c++ class. Then, I create CCAction and run it on the sprite.

                  然后,在我的 init 函数(obj-c 类)中:

                  And after that, when in my init function (obj-c class) do:

                  return self;
                  

                  然后应用程序正在运行,运行和运行,没有任何反应.我在控制台中只收到这条消息:

                  then the app is running, running and running and nothing happens. I receive only this message in console:

                  * -[CCSprite setTexture:],/Users/Michal/..../libs/cocos2d/CCSprite.m:898 中的断言失败响应 SpringBoard 的终止而终止.

                  * Assertion failure in -[CCSprite setTexture:], /Users/Michal/..../libs/cocos2d/CCSprite.m:898 Terminating in response to SpringBoard's termination.

                  我不知道接下来该怎么做...是否可以将 CCSprite/Action 等成功保留在 C++ 类中?

                  I dont know what should I do next... Is it possible to keep CCSprite/Action etc. in C++ class succesfully?

                  推荐答案

                  在尝试像这样使用它之前,请确保已正确初始化纹理:

                  Make sure you have properly initialized the texture before you try to use it like this:

                  CCTexture2D *redButtonNormal = [[CCTextureCache sharedTextureCache] addImage:@"RedButtonNormal.png"];
                  

                  然后初始化精灵(或精灵子类 - 在本例中 spuButton 是 CCSprite 的子类):

                  then initalize the sprite (or sprite subclass - in this example spuButton is a subclass of CCSprite) :

                  spuButton *redButton = [spuButton spuButtonWithTexture:redButtonNormal];
                  

                  注意:因为它是一个子类,所以我必须像这样为它设置 init 方法(如果你是 CCSprite 的子类,你必须这样做):

                  Note: since it is a subclass i had to setup the init methods for it like this (You must do this if you subclass CCSprite):

                  + (id)spuButtonWithTexture:(CCTexture2D *)normalTexture
                  {
                      return [[[self alloc] initWithTexture:normalTexture] autorelease];
                  }
                  
                  - (id)initWithTexture:(CCTexture2D *)aTexture
                  {
                      if ((self = [super initWithTexture:aTexture]) ) {
                  
                          state = kButtonStateNotPressed;
                      }
                  
                      return self;
                  }
                  

                  这篇关于iPhone - cocos2d - 动画和 C++ 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:从 PList 读取字典时的错误顺序 下一篇:使用 Cocos2d 在我的 iPhone 应用程序中使用多个声音

                  相关文章

                • <legend id='Avc41'><style id='Avc41'><dir id='Avc41'><q id='Avc41'></q></dir></style></legend>

                    <tfoot id='Avc41'></tfoot>
                    <i id='Avc41'><tr id='Avc41'><dt id='Avc41'><q id='Avc41'><span id='Avc41'><b id='Avc41'><form id='Avc41'><ins id='Avc41'></ins><ul id='Avc41'></ul><sub id='Avc41'></sub></form><legend id='Avc41'></legend><bdo id='Avc41'><pre id='Avc41'><center id='Avc41'></center></pre></bdo></b><th id='Avc41'></th></span></q></dt></tr></i><div id='Avc41'><tfoot id='Avc41'></tfoot><dl id='Avc41'><fieldset id='Avc41'></fieldset></dl></div>
                    • <bdo id='Avc41'></bdo><ul id='Avc41'></ul>
                    1. <small id='Avc41'></small><noframes id='Avc41'>