-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
export Creator Widget component to Cocos2d-x Layout Node #160
base: master
Are you sure you want to change the base?
Conversation
@@ -220,7 +220,7 @@ let get_tiledmap_path_by_uuid = function (uuid) { | |||
} | |||
} | |||
|
|||
let DEBUG = false; | |||
let DEBUG = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably don't need this in the final PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for review this, I will change it to false
in the final. Are you satisfied with this implement of Widget Component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code itself looks fine to me, but I'm not familiar with positional layouts enough to say one way or the other
@Kuovane thanks for those changes, I have merged your commit into this PR.
|
@drelaptop Just would like to check it is only compatible with Cocos Creator of v1.9 and below right? |
Any updates with this PR? |
What's Widget
Widget is a frequently used UI layout component. It can make the current node automatically align to an optional position of the parent object ......
English Docs, http://www.cocos2d-x.org/docs/creator/manual/en/components/widget.html
中文文档, http://docs.cocos.com/creator/manual/zh/components/widget.html
How to Export
Widget in Creator is a UI layout component, but Widget in Cocos2dx is a base class for all UI class, so we need to export Widget component to Layout class, not Widget class.
To implement those layout feature, I have to add a extra Layout node, and insert the layout node between Node needed layout and its parent node. Meanwhile make the layout location property keep same as layout target.
Existed Limits
Widget in Creator we can set margin value to percentage, but in Cocos2d-x the
Margin
class, only support pixel. So I have no method to support percentage margin.Default align target is the parent node of UI node which existed a widget component, not support custom widget target yet. Might make it done later.
Implement features
Support Widget Align Once, and Align every frame
Support margin pixel value , not percentage value
Only special 9 direction combinations support, not every direction support!
Tests
the Creator Scene is a root canvas and 9 child buttons, canvas size
(960 x 640), run in Simulator:
Export this Scene, and use it in Cocos2d-x cpp test project, change frame size to (960 x 480) (canvas in Creator set Fix Width, cocos2d-x set FIXED_WIDTH)
Export this Scene, and use it in Cocos2d-x cpp test project, change frame size to (480 x 640) (canvas in Creator set Fix Height, cocos2d-x set FIXED_HEIGHT)
TODO
-- the extra Layout node should be delete too, when it's child node removed.
-- try to impl this feature by
ui::LayoutComponent
, other thanRelativeLayoutParameter
andRelativeLayout