Where can I find decent documentation for 9Slice topic.?
Below part is FEEDBACK. You can go through it if you find some time.
So, this is how I proceeded my search for it.
1) I went through the cpp tests but literally, UIScale9SpriteTest.app lakhs lines of code and there is no distinction what is capInset, normal insets(insetBottom, top, etc.) yet some are achieving same effect.
2) Below link is also of no use as first I don’t want to use cocosStudio. Secondly, there is no tutorial given where I can just export this info list for 9slice image! as rest of my project isn’t using cocosStudio.
http://cocos2d-x.org/docs/deprecated/studio-chapters/chapter3/UI/9Slice/en/index.html
3) Check out the 1st topic which explains 9-Slice
http://www.cocos2d-x.org/wiki/CCControlExtension
Again the theory concept explained and corresponding code given has not coherency. Wrong content size given in the code which confused.
Look at this image. 12, 12, 56, 56. And hundred of 12s are shown in image. Which one am I supposed to take? Anyways, it’s not difficult to identity which ones it could be but still.
Secondly, it gives, impression that it my image should be square image. Or should it be? Well, no where I can see in documentation.
Plus
ui::Scale9Sprite *popUp = ui::Scale9Sprite::create("pop-up2.png", CCRectMake(x,y,width,height));
and
ui::Scale9Sprite *popUp = ui::Scale9Sprite::create("pop-up2.png");
popUp->setCapInsets(Rect(x,y, width, height));
ui::Scale9Sprite *popUp = ui::Scale9Sprite::create("pop-up2.png");
1st and 2nd give different results! But as per image, Cap and RectMake are meant to be same.
Also, 2nd and 3rd gives same results which means setCapInset had no clear impact.
4)
Check this properties panel from cocos Studio.
And here it talks about setting x1, x2, y1, y2 but in the documentation given above, it talks about x, y, width, height… They work differently?
5)
In the api link at
http://www.cocos2d-x.org/reference/native-cpp/V3.2/d8/de3/classcocos2d_1_1extension_1_1_scale9_sprite.html#a0f1472e8fb14ea8e5cd70d807c6a9019
Checking all definition says, that it splits the image in 3x3 of equal blocks. Well, didn’t seem to work for me. Or, I think, it’s default if insets aren’t given. (Later I got to know it doesn’t work setScale or ScaleTo action)
6) No mention in programmer’s guide too. But it’s fine… Atleast rest of the other places where it is mentioned, it proved useless as of now.
And I am pretty sure, if I would get the concept, it would simply be 5-10 min of work to write and see the results.
One simple definition would have made the work a lot easier…
It isn’t that I haven’t dug into the material as you can see above!
7)
Now, after nearly 2-3 hours of of try and finding material, I realized that Scale9Sprite doesn’t work with ScaleTo
Actions. And also popUp->setScale()
also makes it work like simply sprite scaling which gets distorted. So, I am simply doing setContentSize which seems to work fine for scaling Up but not Down (bcoz of all 9 are equal blocks) which is fine for me.
And why is setScale is merily given when not mentioned alongside that it will distort image just like simple sprite!.
Definition like below is actual way a documentation should be written where it tells how to use it which is missing from 95% of documentation.
But still, at the end of the day concept remained theoretically clear but not through Apis usage POV. Why? Read below
This is what setCapInsets
tells
Everyone knows the meaning of “set” in setCapInsets
. And same thing with setPrefferedSize
also. I came there to see how can it be used or in context with Scale9Sprite
(some basic diagram could have also helped)
Come On! These 2 were really important concepts to understand scale9Sprite…
Started cocos2d-x ~2.5yrs back and same pain in understanding new concepts. Programmer’s guide was really good initiative from @slackmoehrle but 85% covered topics are easy concepts which are mostly present everywhere on internet and @SonarSystems also have covered them a few times.
I know that cocos2d-x APIs are really awesome and which is why I am sticking to the framework since long. And also it’s package size is too small which is highly appreciable. But Documentation? It takes a heavy toll over all the benefits of cocos.
It’s not complaint. I hope this feedback will be taken in +ve manner. How I proceeded with this concept will give some insights of how is a general way of learning new concept goes in which I guess most of the people will agree
Thanks