Question

I have png file that contents all images, but I can't load images that are beyond 1024*1024.

I tried to load images as texture:

        InputStream istr = CCDirector.sharedDirector().getActivity().getAssets().open(this.src + "balloon.png");
        Bitmap mybit = BitmapFactory.decodeStream(istr);
        istr.close();

        CCTexture2D metexture = new CCTexture2D();
        metexture.initWithImage(mybit);
        for (int i = 0; i < 16; i++)
        {
            CCSpriteFrame myframe = CCSpriteFrame.frame(metexture, CGRect.make(0, i * 128, 80, 128),               CGPoint.make(0, 0));
            this.balloons_images.add(myframe);      
        }

And as part of .plist

    CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames(this.src + "balloon.plist");
    this.addChild(CCSprite.sprite(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("balloon_16.png")), 20);

    ...
    <key>balloon_16.png</key>
    <dict>
        <key>frame</key>
        <string>{{0,1920},{80,128}}</string>
        <key>offset</key>
        <string>{0,0}</string>
        <key>rotated</key>
        <false/>
        <key>sourceColorRect</key>
        <string>{{0,0},{80,128}}</string>
        <key>sourceSize</key>
        <string>{80,128}</string>
    </dict>
    ...

The result is the same. All images beyond 1024 look like stripes.

enter image description here

Is there any way to use images more than 1024*1024?

Was it helpful?

Solution

If you are not using library as jar file, then maybe if you change in class CCTexture2D.java which is in a package org.cocos2d.opengl in this line public static final int kMaxTextureSize = 1024; value to more, for example to 2048, maybe it will be better.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top