Giter VIP home page Giter VIP logo

cocos2d's People

Contributors

alexkarmazin avatar dustinanon avatar genevictor avatar gwennguihal avatar kellymf avatar opengenius avatar shashachu avatar tjhiggins avatar zhouweikuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cocos2d's Issues

CCSprite.setTextureRect Modification

The setTextureRect call should probably be

public void setFlipY(boolean b) {
        if( flipY_ != b ) {
            flipY_ = b; 
            setTextureRect(rect_, contentSize_, rectRotated_);
        }   
    }

instead of

public void setFlipY(boolean b) {
        if( flipY_ != b ) {
            flipY_ = b; 
            setTextureRect(rect_); // uses rect_.size instead of contentSize_
        }   
    }

I noticed this when calling flipY( and flipX for that matter) which then starts the setTextureRect chain. The problem occurs, as I've seen, for frames on sprite sheets whose transparent pixels have been cut out to reduce the space they take.

Blurry Texture When > 1024x1024

Is this normal behavior? Whenever I try to load a PNG with the size of 2048x1024 or 2048x2048, it appears blurry when rendered on the screen.

A 1024x1024 or smaller PNG works fine.

I'm loading these PNGs via CCSpriteFrameCache.addSpriteFrames(file.plist) and drawing CCSprites created by calling CCSprite.sprite("frame", true).

I'm pretty sure it's not because of the hardware, i'm testing on an Atrix 4G that has a GL_MAX_TEXTURE_SIZE of 2048..if that even matters.

3 bugs

Hi ZhouWeikuan,

your project - cocos2d have 3 bugs.

  1. default.properties:android.library=true => android.library=false
  2. org.cocos2d.layers.CCTMXMapInfo: line 260
    positionOffset.x = Integer.parseInt(attributes.getValue("x")) * tileSize.width;
    positionOffset.y = Integer.parseInt(attributes.getValue("y")) * tileSize.height;
    =>
    try {
    positionOffset.x = Integer.parseInt(attributes.getValue("x")) * tileSize.width;
    positionOffset.y = Integer.parseInt(attributes.getValue("y")) * tileSize.height;
    } catch (Exception e) {}
  3. org.cocos2d.layers.CCTMXLayer: line 176
    remove: tile = null;

into4g

CCTexture2D should not use finalize() to clean up GL Textures

Finalizers are not guaranteed to be called in a timely manner if at all and should not be used to release the GL textures.

I performed a local test of unloading the texture whenever CCTextureCache.removeTexture(CCTexture2D) and the native heap memory no longer grows and I no longer receive out of memory errors.

Per http://developer.android.com/reference/java/lang/Object.html#finalize%28%29 you should be using a ReferenceQueue to receive notifications when the WeakReference is garbage collected and perform the clean up then. You will most likely need to subclass WeakReference to store the "_name" value of the texture because it won't be available once the CCTexture2D is garbage collected.

CCTMXLayer > CCTextureAtlas IndexOutOfBoundsException

I'm getting an IndexOutOfBoundsException when I try and load my Tiled maps.

I'm using gzip format and all that jazz. It looks like it might have something to do with the fact that the indices var in (CCTextureAtlas line 159) is a shortbuffer array and that the (int) index is greater than Short.MAX_VALUE; ( It looks like it's flipping to the negative number.) see below.

I'm digging into this, but has anyone else run into this? (or possibly fixed this already??? :D)

public void initIndices() {
for (int i = 0; i < capacity_; i++) {
if (ccConfig.CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP) {
indices.put((short) (i * 6 + 0), (short) (i * 4 + 0));
indices.put((short) (i * 6 + 1), (short) (i * 4 + 0));
indices.put((short) (i * 6 + 2), (short) (i * 4 + 2));
indices.put((short) (i * 6 + 3), (short) (i * 4 + 1));
indices.put((short) (i * 6 + 4), (short) (i * 4 + 3));
indices.put((short) (i * 6 + 5), (short) (i * 4 + 3));
} else {
indices.put((short) (i * 6 + 0), (short) (i * 4 + 0)); <---- (i * 6 + whatever) cast to a short will sometimes give a negative number since you have an int larger than Short.MAX_VALUE;
indices.put((short) (i * 6 + 1), (short) (i * 4 + 1));
indices.put((short) (i * 6 + 2), (short) (i * 4 + 2));

            // inverted index.
            indices.put((short) (i * 6 + 5), (short) (i * 4 + 1));
            indices.put((short) (i * 6 + 4), (short) (i * 4 + 2));
            indices.put((short) (i * 6 + 3), (short) (i * 4 + 3));
        }
    }
    indices.position(0);
}

CCMenuItem and CCMenuItemSprite

org.cocos2d.menus.CCMenuItemSprite
I don't see why there is an overridden draw() method [line 105] , it was actually causing weird behavior [if the selected sprite was a scaled sprite I'd get 2 overlapping sprites]
I did remove it and it worked properly

org.cocos2d.menus.CCMenuItem
The method invocation doesn't work, it throws a NoSuchMethodException
I changed line 54 from
invocation = cls.getMethod(cb, Object.class);
to
invocation = cls.getMethod(cb);

and line 73 from
invocation.invoke(targetCallback, this);
to
invocation.invoke(targetCallback, null);

which worked but was giving me a warning "The argument of type null should explicitly be cast to Object[] for the invocation of the varargs method invoke(Object, Object...) from type Method. It could alternatively be cast to Object for a varargs invocation"

CCDirector.setDeviceOrientation() doesn't correct Sprite dimensions

If you first set the orientation to Landscape, then change to Portrait (or visa versa) and add sprites to a scene, then the sprite will be rotated and positioned correctly, but the dimensions will be wrong.

That is, what was once the width is now the height, and what was once the height is now the width. This makes wide objects look squished horizontally and make tall objects look squished vertically.

I'm trying to fix the problem now, but I don't know if it's been encountered before.

Framerate decreases with SceneTransition

I notice a problem :

When I start just one CCScene, framerate is 60fps, but if I change of scene (2 or more times) with transition, framerate decreases at 30fps. My scenes are very simple :

SplashScreenLayer Scene and Home Scene (the sames for test) :

public static CCScene scene() {
CCScene s = CCScene.node();
SplashScreenLayer layer = new SplashScreenLayer();
s.addChild(layer);
return s;
}

public SplashScreenLayer()
{
    super(ccColor4B.ccc4(0, 0, 0, 255));

    CCTexture2D texture = CCTextureCache.sharedTextureCache().addImage("splashscreen.png");
    CCSprite splashScreen = CCSprite.sprite(texture,CGRect.make(0, 0, 800, 480));
    splashScreen.setPosition(
        ( CCDirector.sharedDirector().winSize().width) / 2,
        ( CCDirector.sharedDirector().winSize().height) / 2
    );

    addChild(splashScreen);

    this.schedule("update");
}

public void update(float dt)
{
    _timeEllapsed += dt;

    C.trace(_timeEllapsed);

    if (_timeEllapsed > _kEndTime)
    {
        this.unschedule("update");
        GameManager.sharedGameManager().changeScene(Constants.SCENE_HOME);
    }
}

GameManager.sharedGameManager().changeScene :

public void changeScene(int sceneID)
{
CCScene newScene;
CCScene oldScene;

    if (CCDirector.sharedDirector().getRunningScene() != null) oldScene = CCDirector.sharedDirector().getRunningScene(); 

    switch (sceneID)
    {
        case Constants.SCENE_SPASH_SCREEN:
            newScene = SplashScreenLayer.scene();
            break;
        case Constants.SCENE_HOME:
            newScene = HomeLayer.scene();
            break;
        default:
            newScene = HomeLayer.scene();
            break;
    }

    if (CCDirector.sharedDirector().getRunningScene() == null)
    {
        CCDirector.sharedDirector().runWithScene(newScene);
    } else
    {
        //CCDirector.sharedDirector().replaceScene(newScene);
        //oldScene = null;
        CCDirector.sharedDirector().replaceScene(CCFadeTransition.transition(_kTransitionDuration, newScene, ccColor3B.ccc3(0, 0, 0)));
    }
}

myrddin (sorry for my english)

How to create the buffer used in GL10.glVertexPointer(int size, int type, int stride, Buffer pointer) ?

I have got the following code in my Cocos2D-iOS program:

CGPoint corners[10];

for(int i = 0; i < 10; i++)
{
corners[i] = CGPointMake(0, 0);
}

glVertexPointer(2, GL_FLOAT, 0, corners);

that I would like to "translate" like this in Cocos2D-Android:

CGPoint[] corners = new CGPoint[4];

for(int i = 0; i < 10; i++)
{
corners[i] = CGPoint.make(0, 0);
}

(CCDirector.gl).glVertexPointer(2, GL10.GL_FLOAT, 0, corners);

but corners should be a "Buffer" according to GL10.glVertexPointer definition.

How to create such a buffer with my CGPoints ?

Thanks !

PS: I am new on Cocos2D-Android, sorry for my potentially trivial questions...

Bitmap exceeds VM budget

I had been banging my head to the wall with this error when loading multiple sprites. I solved it by recycling the bitmap after it was used:

bmp.recycle();
bmp = null;
is = null;

The modified function was the following, in CCTextureCache class:

private static CCTexture2D createTextureFromFilePath(final String path) {

    final CCTexture2D tex = new CCTexture2D();
    tex.setLoader(new GLResourceHelper.GLResourceLoader() {

        public void load() {
            try {
                InputStream is = CCDirector.sharedDirector().getActivity().getAssets().open(path);
                Bitmap bmp = BitmapFactory.decodeStream(is);
                is.close();
                tex.initWithImage(bmp);
                bmp.recycle();
                bmp = null;
                is = null;
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });

    return tex;
}

Can you confirm this bug, or if there is another workaround I am not aware off.

This error seems to happen because GC doesn´t free memory at the needed rate...

CCTMXMapInfo NumberFormatException

parseXMLFile() does not display a friendly error message, the stacktrace().toString() method does not provide any useful information. There are a number of opportunities for a NumberFormatException.

CCOrbitCamera does not rotate about central axis

On my coworker's iPad (using cocos2d-iphone 0.99.4), CCOrbitCamera rotates horizontally about the Y-Axis and rotates vertically about the X-Axis, that is it rotates about the center both ways.

When I use CCOrbitCamera for Android, rotating horizontally always rotates about the left-hand side of the CCNode, and rotating vertically always rotates about the top side of the CCNode.

The code for CCOrbitCamera is a 1:1 translation between cocos2d-android and cocos2d-iphone, so I don't know where this bug is coming from.

As usual, thanks in advance!

Live wallpaper

Hi,
I want to Make a Live wallpaper for my (COCOS2D based) Game.

The live wallpaper service only provides SurfaceHolder (Canvas) But COCOS2D is GLView based .So, How can i make it.
Need help on it

Screen gets Blank-out on 'onPause' & 'onResume'

In my application when i press home button and after that resume my application my textures do not get redraw.I had called CCDirector.onPause and CCDirector.onResume in my Activity`s onPause and onResume.

Do cocos2d supports this functionality if it does then how ? ? ?

i have tried this on cocos2d samples as well and they are behaving same .

CC_DIRECTOR_END - unable to destroy activity

I am getting reports from users for my application using the latest version

Here is the error report:-
java.lang.RuntimeException: Unable to destroy activity {com.mypackage.myactivity}: java.lang.NullPointerException
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3661)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3679)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3795)
at android.app.ActivityThread.access$2400(ActivityThread.java:126)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2042)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4633)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.webkit.WebView.requestFocus(WebView.java:7410)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
at android.view.ViewGroup.requestFocus(ViewGroup.java:1032)
at android.view.View.requestFocus(View.java:3556)
at android.view.ViewRoot.clearChildFocus(ViewRoot.java:1586)
at android.view.ViewGroup.clearChildFocus(ViewGroup.java:508)
at android.view.ViewGroup.clearChildFocus(ViewGroup.java:508)
at android.view.ViewGroup.clearChildFocus(ViewGroup.java:508)
at android.view.ViewGroup.clearChildFocus(ViewGroup.java:508)
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:2207)
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:2181)
at android.view.ViewGroup.removeView(ViewGroup.java:2129)
at org.cocos2d.config.ccMacros.CC_DIRECTOR_END(ccMacros.java:161)
at com.mypackage.myactivity.onDestroy(myactivity.java:434)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3648)

here is the code which i am using to destroy:

@OverRide
public void onDestroy() {

    super.onDestroy();
    ccMacros.CC_DIRECTOR_END();
finish();
}

Kindly help

How to stop Touch dispatcher in inner Layer

Hi i am having problem of touch dispatching from a long time but now after a lot of tries i decided to ask you people .. :D

I created a layer A and layer B and then i add CCMenu in layer B and add layer B in layer A

now Layer A contains Layer B and Layer B contanis CCMenu

Now if i click on CCMenuItem then touches goes to CCMenu and is also dispatched to layer A i do not want to dispatch touch to layer A on touching CCMenu.

Android equivalent of Cocos2D-iOS CCNode.visit() in Cocos2D-Android?

Hi,

I have got the following code in my iOS Coco2D game:

CCSprite *mysprite = [CCSprite spriteWithFile:@"mypng.png"];
// ...Some code here... //
[mysprite visit];

In Coco2D Android, I write:

CCSprite mysprite = CCSprite.sprite("mypng.png");
// ...Some code here... //
mysprite.visit(_GL10 PARAMETER EXPECTED HERE_*);

What should I write as parameter in the visit method ??

Thanks !!

Issue when using using landscape mode

Hi,
When we use
CCDirector.sharedDirector().setDeviceOrientation(CCDirector.kCCDeviceOrientationLandscapeLeft) its having issue when we press lock button.
When we press lock button it calls onPause->onStop->onDestroy.. So we are thrown out of out applicaton.
When we are back from locked screen it shows home screen of phone , because onDestroy called.
But when we use CCDirector.kCCDeviceOrientationPortrait its working fine, I mean it wont call onDestroy and we are resumed to same screen when we are back from lock screen.

Please anybody have faced the issue?
Thanks
-BMR

Slight ghosting when sprites move

This may just be a performance issue, but I noticed that when sprites move (especially in Box2d) there is a slight ghost/phantom image that follows it around.

I've been poking around in the code to see if I can find exactly where this is happening, but I can't seem to put my finger on it. If you could point me in the right direction, I would gladly try to come up with a fix.

Otherwise, if the issue is known and can be resolved easily, I would very much appreciate a fix!

Sprites don't show everytime

Hello,

I develop Android game with cocos2d. I load sprite in this way:
CCSprite sprite = CCSprite.sprite(folder+"/sprite.png");
The problem is that the image sometime is loaded as white square.

Textinput

How can I input text with cocos2d or use native android textfield?

Defect in CCTimer callback update

Sorry if this is not the best way/place to report. I do not know how to branch/commit.

In CCTimer.java:

public void update(float dt) {
    if (elapsed == -1) {
        elapsed = 0;
    } else {
        elapsed += dt;
    }
    if (elapsed >= interval) {
        if(callback != null) {
            //callback.update(dt); // original
            callback.update(elapsed); // fixed
        } else {
            try {
                invocation.invoke(target, elapsed);
            } catch (Exception e) {
                e.printStackTrace();
            }               
        }
        elapsed = 0;
    }
}

random crashes when adding a particle effect from my game loop

First of all - thank you for your great work!

I get (often but not always) this exception when I call the method beneath it:

exception:

09-20 23:11:07.226: ERROR/AndroidRuntime(19287): FATAL EXCEPTION: GLThread 10
09-20 23:11:07.226: ERROR/AndroidRuntime(19287): java.lang.IllegalArgumentException: remaining() < size
09-20 23:11:07.226: ERROR/AndroidRuntime(19287):     at com.google.android.gles_jni.GLImpl.glBufferData(Native Method)
09-20 23:11:07.226: ERROR/AndroidRuntime(19287):     at org.cocos2d.particlesystem.CCQuadParticleSystem$1.load(CCQuadParticleSystem.java:88)
09-20 23:11:07.226: ERROR/AndroidRuntime(19287):     at org.cocos2d.opengl.GLResourceHelper$1.perform(GLResourceHelper.java:68)
09-20 23:11:07.226: ERROR/AndroidRuntime(19287):     at org.cocos2d.opengl.GLResourceHelper.update(GLResourceHelper.java:128)
09-20 23:11:07.226: ERROR/AndroidRuntime(19287):     at org.cocos2d.nodes.CCDirector.drawCCScene(CCDirector.java:700)
09-20 23:11:07.226: ERROR/AndroidRuntime(19287):     at org.cocos2d.nodes.CCDirector.onDrawFrame(CCDirector.java:665)
09-20 23:11:07.226: ERROR/AndroidRuntime(19287):     at org.cocos2d.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1245)
09-20 23:11:07.226: ERROR/AndroidRuntime(19287):     at org.cocos2d.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1056)

method (class is a CCLayer):

    public void explode(float x, float y)
    {
        CCParticleSystem emitter;
        emitter = CCParticleExplosion.node();
        emitter.setTexture(CCTextureCache.sharedTextureCache().addImage("fire.png"));
        emitter.setAutoRemoveOnFinish(true);
        emitter.setPosition(x, y);
        emitter.setSpeedVar(300);
        emitter.setDuration(2.2f);
        emitter.setSpeed(600);
        addChild(emitter);
    }

It works every time when I call this in ccTouchesBegan but calling this from my game loop leads most of the time (but strangely enough not everytime) to the posted exception.
Can you tell me what I am probably doing wrong?

CCMenuItemSprite images not visible (w/ fix)

Selected and disabled image not being displayed. Visible flags not being set. See code below for my fix. Maybe there's a better way though.

@Override
public void draw(GL10 gl) {
    if (isEnabled_) {
        if (isSelected_) {
            normalImage_.setVisible(false);
            selectedImage_.setVisible(true);
            selectedImage_.draw(gl);
        } else {
            normalImage_.setVisible(true);
            selectedImage_.setVisible(false);
            normalImage_.draw(gl);
        }
    } else {
        if (disabledImage_ != null) {
            normalImage_.setVisible(false);
            disabledImage_.setVisible(true);
            disabledImage_.draw(gl);

            // disabled image was not provided
        } else {
            normalImage_.setVisible(true);
            disabledImage_.setVisible(false);
            normalImage_.draw(gl);
        }
    }
}

Nexus S & Nexus One VM budget issue

Hi,
My Game is crashing on CCtextureCache.createBitmap on Nexus Devices but working fine on all other devices even it is crashing on Nexus S and not crashing on LG Optimus.
What is happening . Anyone please help me.

Null pointer exception with CCRenderTexture.renderTexture(int width, int height)

I just want to create a CRenderTexture with this simple code:

CCRenderTexture rt = CCRenderTexture.renderTexture(width, width);//width and height have the same values

But it returns a null pointer exception.

The issue occurs in the CCRenderTexture class when the object is initialized:

protected CCRenderTexture(int width, int height) {
GL11ExtensionPack egl = (GL11ExtensionPack)CCDirector.gl;
egl.glGetIntegerv(GL11ExtensionPack.GL_FRAMEBUFFER_BINDING_OES, oldFBO_, 0);
///ETC....
}

Indeed, "CCDirector.gl" is equal to null which induces that "egl" is equal to null => crash on egl.glGetIntegerv(...).

Somebody knows how to fix this bug ? (which seems due to the Android Coco 2D framework)

Thanks !!!

How to Add Android Widgets (E.g Gallery) to a CCLayer

Hi, what would be the best way to add an android widget to a CCLayer. I have tried using CCDirector.sharedDirector().attachInView(mygaller), have tried passing a reference to the original activity and calling .addView on it, but still it doesnt work. Rather my game just hangs there and does load the next layer (and no error is shown on the debug screen). I believe there should be a work around to this, or a proper design principle which I am unfamiliar with.
I would greatly appreciate some assistance.

Memory issure again!!!

CCTexutre2d have using "GLResourceHelper.GLResourceLoader mLoader".
So,when we set ccsprite = null,the ccsprite have not realize release,because "CCTexutre2d.finalize" will not be called.Your could add code about "GLResourceHelper.sharedHelper().removeLoader(mLoader);" in CCTexutre2d.

Thank you

CCRenderTexture and emulator

If I use CCRendertexture I can not test the apps in the android-emulator. The following error appears (i replaced my app-name with XXX):

03-23 10:30:26.118: E/AndroidRuntime(896): FATAL EXCEPTION: GLThread 105
03-23 10:30:26.118: E/AndroidRuntime(896): java.lang.UnsupportedOperationException: glGenRenderbuffersOES
03-23 10:30:26.118: E/AndroidRuntime(896): at com.google.android.gles_jni.GLImpl.glGenRenderbuffersOES(Native Method)
03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.opengl.CCRenderTexture.(CCRenderTexture.java:69)
03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.opengl.CCRenderTexture.renderTexture(CCRenderTexture.java:43)
03-23 10:30:26.118: E/AndroidRuntime(896): at XXX.loadSprites(SplashScene.java:43)
03-23 10:30:26.118: E/AndroidRuntime(896): at XXX.SplashScene.onEnter(SplashScene.java:37)
03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.nodes.CCDirector.setNextScene(CCDirector.java:1238)
03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.nodes.CCDirector.drawCCScene(CCDirector.java:705)
03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.nodes.CCDirector.onDrawFrame(CCDirector.java:665)
03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1245)
03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1056)

I think it is a bug in the emulator, but is it possible to use an other openGL-Function to replace glGenRenderbuffersOES?

CCTMXTileLayer not retrieving tiles

when calling tileAt() I keep getting a null value, tile not found. Upon closer inspection it seems that line 176 if causing the problem. Setting the tile to null, inside the code block that creates a new tile.

Memory issue

We are facing memory issue in cocos2d android. A class name as GLResourceHelper increases its size dramatically. Whenever we call removealltextures after this when we reload the textures again this GLResourceHelper gain its size to 1 mb + every time. Please fix this issue as soon as possible.

Regards

Shahbaz Sajjad

CCRenderTexture disappears after pressing the home button

I create a CCRenderTexture (inTexture) and put this texture into a Sprite (cardSprite)

cardSprite = CCSprite.sprite(inTexture.getSprite().getTexture());

This works fine in the game. But when I press the home button and go back to the game the Texture has disappeared. If I use a normale Texture (for example the texture of another I sprite initalised with a png-Texture) then the Texture don't disappear.

So it seems that there is a bug in CCRendertexture that makes this texture disappear after resume.

bitmap size exceeds VM budget

In CCTexture2D.java, the method "public void initWithImage(Bitmap)" does not seem to call recycle() on the provided bitmap under all circumstances. I think the OOM issues I have been running into are a result of this. I temporarily fixed this by calling recycle on the bitmap at the end of the routine.

Textures not being released

Hi,
I am trying to remove all textures from CCTextureCache to free up memory from native Heap . I am using CCTextureCahce.purgeSharedTextureCache() but its not cleared as expected.
For example if size of my native heap is 10MB before clearing than after calling purgeSharedTextureCache it is again 10MB. :(

Actually in my app at a point i want to release all textures from memory and than reload new textures from scratch.
please help.

memory allocation when using CCSprite array

Hi everyone,
I have some confusion related to memory allocation.
Suppose I need an array of sprites.
I will declare them as
CCSprite mySprites = new CCSprite[MAX_SPRITES];
and while creating i will create them and add to current layer like:
for(int i=0;i<MAX_SPRITES;i++)
{
mySprites[i] = CCSprite.sprite("image_"+i+".png");
this.addChild(mySprites[i]);
}

Now sprites are added to layer but we need to access them while game flow so we will use mySprites;
So my question is when we do this.removeAllChildren(true); for this layer, will it remove all children and also mySprites sprites?
Or do we need to do something like this
for(int i=0;i<MAX_SPRITES;i++)
{
mySprites[i] = null;
}

In my game I think memory is leaking if there is simillar case.

We can also use tags to retrive sprites instead of using "CCSprite mySprites = new CCSprite[MAX_SPRITES];".

Please can you tell me what is the solution for this?

Thanks.

Live particles' Y position changes even w/ kCCPositionTypeFree

Source says that if you set the position type of a particle system to kCCPositionTypeFree, then /** If the emitter is repositioned, the living particles won't be repositioned */. However, when I reposition the emitter, the X position of live particles don't change, but the Y does...

Can't retrieve tile properties

The following should return the properties for a tile:

propertiesHashMap = _map.propertiesForGID( layer.tileGIDAt( point ) );

It seems that the poperties for a tileset's GIDs do not match up with the map's GID's. The tile's GID's are numbered 1 through tileset size, so if there are 16 tiles, then it has GIDs 1 through 16. The map's GID's are generated in some other manner. Example is 637534208.

So when I get the tile by GID at a point on the layer it returns 637534208. When I use this GID to get the tile properties for that tile I get an error or null.

how to create CCTMXTiledMap?

i try encoding=base64 and uncompress ".tmx" file, encoding=base64 and compress="gzip" ".tmx" file and encoding=base64 and compress="zlib" ".tmx" file.
the way of uncompress and zlib is failed and throw exception, and the way of gzip that create the CCTMXTiledMap success has render issue.
is latest version of cocos2d unsupport ".tmx" file created by Tiled?

Request: Load Sounds from Assets or SDCard

Right now it seems that we can only load sounds from the res folder, and that is a major inconvenience for my work. I've tried to roll my own SoundManager, but there is something that I'm not grasping about loading from those two places.

If someone more skilled than myself could expand the functionality of SoundManager to support Assets and SDCard I would be greatly appreciative!

CCMenu with no Items

Currently, if you instantiate a CCMenu without any children and add it to another node, the code flips out during some operations (ex. itemForTouch) because its list of children is null.

Maybe add some null checks or..ditch the lazy allocations? I'm not sure.

It would be nice if you are able to add CCMenu's to other nodes without the menu having any children..unless that is against the cocos2d spec. There are cases where it would be ideal to have an empty menu where the items get added later on due to some game logic.

Thanks!

Big issues

FPS keeps dropping, and at the end it crashes.
Please can anyone help me how to solve this?
Thanks in advance.

native back button

in game scene,when press the NATIVE back button,the application was turn off.can I holding the back button?
the code for the layer:
setIsKeyEnabled(true);
@OverRide
public boolean ccKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (keyCode == KeyEvent.KEYCODE_BACK) {
CCDirector.sharedDirector().popScene();
return true;
}
return super.ccKeyDown(keyCode, event);
}
not useful...
please help me.

issue related to CCLable holding strong ref to texture

Hi,
There was an issue like:
"Eclipse's memory analyzer points out that GLResourceHelper.reloadMap is holding some CCLabel as hash values, which are considered strong references. The labels are too strongly referencing the textures."

In last update of cocos2d android CCLabel.java and CCTexture2D.java were changed.
So is this issue solved now?
Will CCLable leak memory now?

Thanks.

I can't get multi touch to work in ccTouchesMoved()

I can't get multi touch to work in ccTouchesMoved(). It works correctly in ccTouchesBegan(), but in ccTouchesMoved() I get only event from ActionIndex=0.

It's my fault or is it a bug?

This is the code of my Layer:

public class HelloWorldLayer extends CCColorLayer {

    private static final String TAG = "Cocos2D";
    private CCSprite xRed;
    private CCSprite xGreen;

    protected HelloWorldLayer(ccColor4B color) {
        super(color);
        this.setIsTouchEnabled(true);

        xRed = CCSprite.sprite("x-red.png");
        xGreen = CCSprite.sprite("x-green.png");
    }

    @Override
    public boolean ccTouchesBegan(MotionEvent event) {
        int pointerIndex = event.getPointerId(event.getActionIndex());
        CGPoint location =  CCDirector.sharedDirector().convertToGL(CGPoint.ccp(event.getX(pointerIndex),event.getY(pointerIndex)));
        Log.d(TAG, String.format("touch %d=(%f,%f)", event.getActionIndex(), location.x,location.y));

        switch (event.getActionIndex()) {
            case 0:
                xRed.setPosition(location);
                addChild(xRed);
                break;
            case 1:
                xGreen.setPosition(location);
                addChild(xGreen);
                break;
            default:
                break;
        }

        return super.ccTouchesBegan(event);
    }

    @Override
    public boolean ccTouchesMoved(MotionEvent event) {
        int pointerIndex = event.getPointerId(event.getActionIndex());
        CGPoint location =  CCDirector.sharedDirector().convertToGL(CGPoint.ccp(event.getX(pointerIndex),event.getY(pointerIndex)));
        Log.d(TAG, String.format("move %d=(%f,%f)", event.getActionIndex(), location.x,location.y));

        switch (event.getActionIndex()) {
            case 0:
                xRed.setPosition(location);
                break;
            case 1:
                xGreen.setPosition(location);
                break;
            default:
                break;
        }

        return super.ccTouchesMoved(event);
    }

    @Override
    public boolean ccTouchesEnded(MotionEvent event) {
        Log.d(TAG, "ccTouchesEnded");
        int pointerIndex = event.getPointerId(event.getActionIndex());
        CGPoint location =  CCDirector.sharedDirector().convertToGL(CGPoint.ccp(event.getX(pointerIndex),event.getY(pointerIndex)));
        Log.d(TAG, String.format("touch %d=(%f,%f)", event.getActionIndex(), location.x,location.y));     

        switch (event.getActionIndex()) {
            case 0:
                removeChild(xRed, true);
                break;
            case 1:
                removeChild(xGreen, true);
                break;
            default:
                break;
        }

        return super.ccTouchesEnded(event);
    }

    public static CCScene scene() {
        CCScene scene = CCScene.node();
        CCLayer layer = new HelloWorldLayer(ccColor4B.ccc4(255, 255, 255, 255));

        scene.addChild(layer);

        return scene;
    }
}

GLException: out of memory on large project

I have a project with 17 scenes and approximately 40Mb images. On every scene is about 10-20 Sprites with animation.
If i change scenes from first to last and back - application (device - Samsung Galaxy Tab 10.1, Android 3.2) have a dumped and closed.

I set
mGLSurfaceView.setDebugFlags(CCGLSurfaceView.DEBUG_CHECK_GL_ERROR);
in Activity, and see in LogCat, that is error:
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): FATAL EXCEPTION: GLThread 10
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): android.opengl.GLException: out of memory
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): at android.opengl.GLErrorWrapper.checkError(GLErrorWrapper.java:62)
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): at android.opengl.GLErrorWrapper.glDrawArrays(GLErrorWrapper.java:258)
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): at org.cocos2d.nodes.CCSprite.draw(CCSprite.java:915)
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): at org.cocos2d.nodes.CCNode.visit(CCNode.java:740)
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): at org.cocos2d.nodes.CCNode.visit(CCNode.java:746)
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): at org.cocos2d.nodes.CCNode.visit(CCNode.java:746)
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): at org.cocos2d.transitions.CCTransitionScene.draw(CCTransitionScene.java:76)
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): at org.cocos2d.nodes.CCNode.visit(CCNode.java:740)
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): at org.cocos2d.nodes.CCDirector.drawCCScene(CCDirector.java:716)
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): at org.cocos2d.nodes.CCDirector.onDrawFrame(CCDirector.java:665)
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): at org.cocos2d.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1245)
12-26 22:05:45.690: ERROR/AndroidRuntime(11013): at org.cocos2d.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1056)

I insert releasing textures in my scenes and CCTextureCache, something like this:

public void removeUnusedTextures() {
    HashMap<String, Integer> tempSet = (HashMap<String, Integer>) _texturesRefCount.clone();
    for (String key : tempSet.keySet()){
        String nKey = key;
    if (_texturesRefCount.get(nKey) <= 0){
            WeakReference<CCTexture2D> texWR = textures.get(nKey);
            if (texWR != null){
                CCTexture2D tex = texWR.get();
                if (tex != null){
                    tex.releaseTexture(CCDirector.gl);
                }
            }
            textures.remove(nKey);
            _texturesRefCount.remove(nKey);
        }
    }

}
And call it before scene transitions do. Size of CCTextureCache.textures hashmap not exceed of 50-60 cached textures.
This is a decrease a chance to application crash and i can do more scene transitions, than before, but i still to get crash after a some time.
_texturesRefCount - is a hashmap, i add it to CCTextureCache and increase/decrease counters for my textures.

I use sources, not a jar. Also i see all issues on this subject there and in other places, and try some solutions - noone was to work correct.

What's right way to release resources between different scenes? Does cocos2d automatically texture release, or i need to release it manually?

TMX map display not correct

What steps will reproduce the problem?

  1. first open the tmx map in init function
  2. secone debug step by step,can open tmx and load layers,then goto the scene function in CCLayer Class;
  3. when finish the this.addChild(),and return the scene,the map displayed on screen is not correct;

What is the expected output? What do you see instead?
i should see a right displayed tiled map,but i see a lot of black tile and some my tile across the whole map;

What version of the product are you using? On what operating system?
i use the current version , check out with git; On Mac X10.6.7 with eclipse and android2.2;

Please provide any additional information below.
base64 gzip encoding map;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.