Another features request for further releases - FilledPolygon, WrappedText, Clip Node etc.

Hi Guys,

How about to implement/include some another new features (additionaly to mentioned in http://www.cocos2d-x.org/boards/6/topics/5775)?

  1. Filledpolygon - I think would be usefull (e.g. for rendering some polygon landscape areas filled with a texture) addon for game developer. I used it in my game.
    There is cocos2d (iPhone) project at:
    https://github.com/asinesio/cocos2d-PRKit
    I’ve ported it to cocos2dx, may attach my files if necessary.
  2. Would be useful to have wrapped text node (that will wrap text to specified width) - to render descriptions, stories, etc. for game. Unfortunatelly have no code for that.
  3. Would be useful to have Clip node - might be used for scroll boxes, wrapped text, etc. Also have no code for this.
  4. Woudl be useful to have FileExists functionality. E.g. if some “game objects” have additional textures (with definite naming convention) and some don’t and we need to create these additional textures if files exists and not create otherwise - I used this approach in my game (had to use native marmalade API). I know e.g. CCTextureCache::addImage will return NULL texture if file doesn’t exist but why make redundant operations if file simply doesn’t exist?
  5. How about to include some TTF to FNT converting tool to cocos? TTF is already implemented for all platforms but it still performs slower than BMFont (?). I used hiero.jnlp - java tool, since TTF was not implemented in 0.9.x.

Thanks,
Alex

Hi alex,
can you share your PRKit code?

Hello everyone,
I’ve ported Additions Filledpolygon from cocos2d-iphone (project at: https://github.com/asinesio/cocos2d-PRKit) to cocos2d-x.

I hope can be useful.
D.

I made a Cocos2d-X 2.0 port of your PRKit code

Thanks, you’ve anticipated my post

:wink:

awesome, this is what I want great work

Damiano Mazzella wrote:

Hello everyone,
I’ve ported Additions Filledpolygon from cocos2d-iphone (project at: https://github.com/asinesio/cocos2d-PRKit) to cocos2d-x.
>
I hope can be useful.
D.

Yes, it is a very useful thing, i use it in my project! Good job. But i have one question there - http://www.cocos2d-x.org/boards/6/topics/12325
Maybe you know answer?

It’s very useful. but I can not download it.

Herman Jakobi wrote:

I made a Cocos2d-X 2.0 port of your PRKit code

I used your cocos2d-x 2.0 PRKit code, But it cann’t draw the PRFilledPolygon on the layer, following is my test code and I also attach the image file watermelon.png:

Vector2dVector vc;
vc.push_back(Vector2d(5,15));
vc.push_back(Vector2d(6,13));
vc.push_back(Vector2d(32,5));
vc.push_back(Vector2d(48,7));
vc.push_back(Vector2d(6,14));
vc.push_back(Vector2d(34,59));
vc.push_back(Vector2d(28,59));
CCTexture2D* texture = CCTextureCache::sharedTextureCache()>addImage;
PRFilledPolygon *filledPolygon = PRFilledPolygon::filledPolygonWithPointsAndTexture;
filledPolygon
>setPosition(0,320);
this->addChild(filledPolygon,1);
Do you know what is wrong?

Try this:

filledPolygon->setAnchorPoint(ccp(0, 0));
filledPolygon->setPosition(ccp(0,0));
this->addChild(filledPolygon, 1);

I have tried it,but the result all the same.

Maybe my PRKIT code has some bug, I appriciate that you can share the PRKIT code on cocos2d-x you always use.
Thanks you.

Do you have error when compile program?

Alex Zhd wrote:

Do you have error when compile program?

No,It built smoothly;

I’m also trying to get this to work. I’m running a cocos2d-iphone PRKit example alongside it with the same texture, and have confirmed that the polygon is correctly triangulated and all the texture coordinates are the same going into the draw function, but no texture appears on screen.

What would be a really great feature for CCDrawingPrimitives would be a ccDrawTexturedPoly(…) =)

Craig

Hi all,
sorry but I’ve been away for the holidays :slight_smile:

I attach the new version of PRKit for cocos2d-x 2.0.

I hope you find it useful,
D.

Damiano Mazzella wrote:

Hi all,
sorry but I’ve been away for the holidays :slight_smile:
>
I attach the new version of PRKit for cocos2d-x 2.0.
>
I hope you find it useful,
D.

The port is buggy on windows (and it crashes), BUT both on Windows and OS X iOS simulator, it doesnt triangulate as it should. I’ve attached an image to show what I mean.

Here’s the code:

init method:@
Vector2dVector vc;
CCTexture2D texture = CCTextureCache::sharedTextureCache~~>addImage;
filledPolygon = PRFilledPolygon::filledPolygonWithPointsAndTexture;
this~~>addChild;
@
update method:@
Vector2dVector vc;
for ; it != particles.end; ++it) {
Particle
p = *it;
vc.push_back(Vector2d(mul * p~~>x, mul * p~~>y));
}
filledPolygon->setPoints(vc);
@

Bojan Drvarek wrote:

Damiano Mazzella wrote:
> Hi all,
> sorry but I’ve been away for the holidays :slight_smile:
>
> I attach the new version of PRKit for cocos2d-x 2.0.
>
> I hope you find it useful,
> D.
>
The port is buggy on windows (and it crashes), BUT both on Windows and OS X iOS simulator, it doesnt triangulate as it should. I’ve attached an image to show what I mean.
>
Here’s the code:
>
init method:@
Vector2dVector vc;
CCTexture2D texture = CCTextureCache::sharedTextureCache~~>addImage;
filledPolygon = PRFilledPolygon::filledPolygonWithPointsAndTexture;
this~~>addChild;
@
>
update method:@
Vector2dVector vc;
for ; it != particles.end; ++it) {
Particle
p = *it;
vc.push_back(Vector2d(mul * p~~>x, mul * p~~>y));
}
filledPolygon->setPoints(vc);
@

Hi,
is you image NPOT?
Can you post slime_1.png used for test?

Ciao,
D.

Damiano Mazzella wrote:

Hi all,
sorry but I’ve been away for the holidays :slight_smile:
>
I attach the new version of PRKit for cocos2d-x 2.0.
>
I hope you find it useful,
D.

I’ve been testing it for a while and it seems to work great - thank you!

Damiano Mazzella wrote:
>

Hi,
is you image NPOT?
Can you post slime_1.png used for test?
>
Ciao,
D.

Image is POT, I’m sending it as attachment. Does the point list need to be inputted in specific order or does the triangulator sort them out in format compatible with OpenGL?