2youyou2 / Flash2Cocos2d-x

use this tool you can export the flash data, and use the data in cocos2d-x game
90 stars 67 forks source link

Patching CCNode is a bad idea #2

Open farwayer opened 11 years ago

farwayer commented 11 years ago

Thx a lot for this awesome tool! But it's painful to update cocos2d-x engine to new version. And it's look very bad to patch internal engine classes. Any chance to take out additional affine transform's from CCNode class?

2youyou2 commented 11 years ago

I agree with you. But i didn't find a way to take out additional affine transform. If use function like setPosition(), it will be too much trouble.

farwayer commented 11 years ago

At this moment I see two way to make it without patching CCNode and without use setScale(), setPosition() etc.:

  1. Subclass CCSprite (you use it for display, right?) and override nodeToParentTransform() like this:

CCAffineTransform CCMySprite::nodeToParentTransform(void) { CCAffineTransform transform = CCSprite::nodeToParentTransform(); if (m_bTransformDirty) transform = CCAffineTransformConcat(transform, m_tOtherTransform); return transform; }

and use it for display.

  1. Set shader program to CCSprite for additional affine transform

I would help, but I have no time now.

2youyou2 commented 11 years ago

Display can be many type, like particle, so subclass CCSprite do not satisfy requirement. Maybe set shader program to CCSprite for additional affine transform wiil be a good idea, but i am not familiar with shader.

oktears commented 9 years ago

你好,我下载了fla的demo,导入库中元件的时候提示:未在 Fla 发生 JavaScript 错误。ReferenceError: Skeleton is not defined, 库中找到符合骨架结构的元件!