1. <small id='qdNyx'></small><noframes id='qdNyx'>

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

          <bdo id='qdNyx'></bdo><ul id='qdNyx'></ul>

        cocos2d-android:如何显示分数

        cocos2d-android: how to display score(cocos2d-android:如何显示分数)
          <tfoot id='quQK7'></tfoot>
              <bdo id='quQK7'></bdo><ul id='quQK7'></ul>

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

                  <small id='quQK7'></small><noframes id='quQK7'>

                  本文介绍了cocos2d-android:如何显示分数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在更新方法中添加了 CCLabel 以显示我的游戏分数.
                  它在分数提高到 5000 之前运行良好.之后 logCat 显示消息:

                  I added CCLabel in my update method to display my game score.
                  It works well before score raise to 5000. After that logCat shows the messege:

                  02-08 11:47:37.476: E/dalvikvm-heap(4190): 1048576-byte external allocation too large for this process.
                  02-08 11:47:37.476: E/dalvikvm(4190): Out of memory: Heap Size=14343KB, Allocated=13585KB, Bitmap Size=2078KB
                  java.lang.reflect.InvocationTargetException......
                  caused by java.lang.OutOfMemoryError
                  

                  我的代码是:

                  countScore++ ;
                  Log.e("total Score:", "" + countScore);
                      CCLabel labelScore = CCLabel.makeLabel("" + countScore, "DroidSans", 20);
                  
                      labelScore.setColor(new ccColor3B(1,1,1));
                      labelScore.setPosition(CGPoint.ccp(50, 50));
                      addChild(labelScore, 11);
                      labelScore.setTag(11);
                      _labelScores.add(labelScore);
                      CCCallFuncN actionMoveDone1 = CCCallFuncN.action(this, "labelFinished");
                      CCSequence action = CCSequence.actions(actionMoveDone1);
                      labelScore.runAction(action);
                  

                  如何解决?

                  推荐答案

                  我认为您每次需要时都在创建 CCLabel.

                  I think you are creating CCLabel every time when you need.

                  CCLabel labelScore = CCLabel.makeLabel("" + countScore, "DroidSans", 20);
                  labelScore.setColor(new ccColor3B(1,1,1));
                  labelScore.setPosition(CGPoint.ccp(50, 50));
                  addChild(labelScore, 11);
                  labelScore.setTag(11);
                  

                  不要那样做.
                  将您的 ScoreLable 设置为全局变量,并在构造函数中完成它的初始化、颜色设置和定位.在您的情况下,仅使用以下代码.

                  Don't do that.
                  Set your ScoreLable as global variable and complete its initialization, color setting and positioning in constructor. In your condition use only following code.

                  labelScore.setString("" + countScore);
                  

                  这篇关于cocos2d-android:如何显示分数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
                  Resume game cocos2d(恢复游戏 cocos2d)
                  Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
                  Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
                  How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)

                  1. <legend id='sED5X'><style id='sED5X'><dir id='sED5X'><q id='sED5X'></q></dir></style></legend>

                          <tbody id='sED5X'></tbody>
                        <tfoot id='sED5X'></tfoot>
                        <i id='sED5X'><tr id='sED5X'><dt id='sED5X'><q id='sED5X'><span id='sED5X'><b id='sED5X'><form id='sED5X'><ins id='sED5X'></ins><ul id='sED5X'></ul><sub id='sED5X'></sub></form><legend id='sED5X'></legend><bdo id='sED5X'><pre id='sED5X'><center id='sED5X'></center></pre></bdo></b><th id='sED5X'></th></span></q></dt></tr></i><div id='sED5X'><tfoot id='sED5X'></tfoot><dl id='sED5X'><fieldset id='sED5X'></fieldset></dl></div>

                        <small id='sED5X'></small><noframes id='sED5X'>

                        • <bdo id='sED5X'></bdo><ul id='sED5X'></ul>