Hi,
Just a heads up the cocos2d-x 3.1 runtime example project has not been updated for iOS and android.
Hi,
Just a heads up the cocos2d-x 3.1 runtime example project has not been updated for iOS and android.
Aye, I'll probably leave it like that for a bit while I focus on cocos2d-x v2, cocos2d v3, cocos2d v2... :bang: If anyone wants to fix up those projects, that would be most welcome! :love:
Cool, currently getting a problem with spine included in my project with the PolygonBatch.h file...
#ifndef SPINE_POLYGONBATCH_H_
#define SPINE_POLYGONBATCH_H_
#include "cocos2d.h"
namespace spine {
class cocos2d::Texture2D;
the line "class cocos2d::Texture2D;" i have to comment out in order to compile (error = "Cannot define or redeclare Texture2D here because namespace 'spine' does not enclose namespace 'cocos2d'"), but i'm getting black squares where the textures of spine should be. So guess once i work out what I've done wrong things will work.
I just deleted the forward declaration, it isn't needed. Not sure on the black textures though.
Nate :I just deleted the forward declaration, it isn't needed. Not sure on the black textures though.
It's strange as only spine skeleton that appears to work is one in splash screen although its now showing as if i have to now premultiply the textures. I assume i shouldn't have to re-export my spine anims for the new runtime?
Oh yes, out of interest is there such a thing as a texture unpacker, that unpacks the atlas files, for cases where you lose the original artwork?
Premultiplied alpha is the only way to get proper blending, so it is the default. This is true for all blending, not just with Spine. If you don't premultiply, you can do setOpacityModifyRGB(false)
on the SkeletonAnimation
.
Maybe you can do a PR for the iOS project and I can test it?
Well i found out what was causing the blank textures, as to it happening I'm not sure if it should..
A bit of background story, i have a large app with a lot of spine assets on each page, i noticed memory use each page kept going up and up despite me doing things correctly. It turned out the texture cache was just getting to big. So i added the following line to clear the cache at key points.
Director::getInstance()->getTextureCache()->removeUnusedTextures();
Previously this would de-allocate any textures that where unused even things like old background images (non spine) etc...
What is happening now is the textures are being removed despite spine currently using them. So appears to me to indicate the textures used in spine are not incrementing the reference count now.
I took your advice and being lazy and a programer i knocked up a quick tool to check all my png's where pre-multiplied alpha or not and batch convert them all to pre-multiplied. Saved me a lot of time . Now everything looks and works perfect apart from above.
Update: think i found reason... spine-cococs2dx.h needs to be updated as follows...
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path);
texture->retain();
self->rendererObject = texture;
self->width = texture->getPixelsWide();
self->height = texture->getPixelsHigh();
}
void _spAtlasPage_disposeTexture (spAtlasPage* self) {
((Texture2D*)self->rendererObject)->release();
}
Makes sense, will add the retain/release. Thanks!
I was thinking, maybe we should target cocos2d-x 3.0 since 3.1 is under development. Originally I wanted to do 3.1 because rendering is different, but nothing in cocos2d-x actually helped me with rendering anyway, I had to write my own PolygonBatch. I think I'd rather target only cocos2d-x stable releases.
Its a tough choice as 3.1 is currently at rc0 stage, and at rate they have been doing things means release version will be out in a few weeks. For my project I took the decision of doing my game with then 3.0 beta and have been tracking changes from there. I knew by time i finished project version 3.0 would be final, now I'm still doing game and 3.1 is almost final . At least upgrading my project as i go saves me from doing lots and lots of updates
I ended up just supporting 2, 3, and 3.1.
https://github.com/EsotericSoftware/spi ... e-cocos2dx
They aren't so different, though it's a bit annoying to keep them all in sync. I'll probably retire 2 when it gets old enough.
hi,nate!
I want to remove the texture after the sprine has been removed,but it dosen't work.
I logout the CachedTextureInfo in lua before remove it
print("this leftSoldiers getReferenceCount",v.sprite:getReferenceCount())
It show that the spine's ReferenceCount is 1.It's right.
I logout the CachedTextureInfo in lua after remove the spine 1 second.
print(cc.Director:getInstance():getTextureCache():getCachedTextureInfo())
It show that the spine's texture ReferenceCount is 2!!!
so,how can I release the texture.
I had add a breakpoint in
void spAtlas_dispose (spAtlas* self) {
spAtlasRegion* region, *nextRegion;
spAtlasPage* page = self->pages;
while (page) {
spAtlasPage* nextPage = page->next;
spAtlasPage_dispose(page);
page = nextPage;
}
region = self->regions;
while (region) {
nextRegion = region->next;
spAtlasRegion_dispose(region);
region = nextRegion;
}
FREE(self);
}
But it never come here!