I ported all RubeLayer related files to c++. In ButtonRUBELayer it have 'selector' and 'sceneClassType' my question can i do something similar in c++? i am pretty new to c++ and googling around didnt find anything.
bi.selector = NSSelectorFromString( [NSString stringWithUTF8String:bi.selectorName.c_str()] );
bi.sceneClassType = NSClassFromString( [NSString stringWithUTF8String:bi.sceneName.c_str()] );
Much Thanks!
ButtonRUBELayer
Re: ButtonRUBELayer
I just did the same myself
You can find a sample loader for RUBE using cocos2d-X at this page:
http://www.iforce2d.net/rube/?panel=loaders
Setup video here if you're using Xcode: http://www.youtube.com/watch?v=ePTR5lHE4q0
Unfortunately in C++ it's not possible to have a 'Class' type which makes this so easy in ObjC. So I have not implemented the scene switching button feature at all.
However, you can pass around function references in C++, so I have implemented the other button feature (function selectors). The catch is that you need to register all the functions you want to use in the C++ code, so it's still not as flexible as the ObjC method.
The best way to see what I'm talking about is to download the source from the loaders page linked to above, and look at MenuScreenRUBELayer.cpp which is a simple example of extending BasicRUBELayer. The important point is in the constructor, where the string name to be used in RUBE is matched with a function in the class. In that example, I have made the function switch the scene, so even if we can't have the more flexible method of simply setting the class name in RUBE directly, it's not the end of the world.

You can find a sample loader for RUBE using cocos2d-X at this page:
http://www.iforce2d.net/rube/?panel=loaders
Setup video here if you're using Xcode: http://www.youtube.com/watch?v=ePTR5lHE4q0
Unfortunately in C++ it's not possible to have a 'Class' type which makes this so easy in ObjC. So I have not implemented the scene switching button feature at all.
However, you can pass around function references in C++, so I have implemented the other button feature (function selectors). The catch is that you need to register all the functions you want to use in the C++ code, so it's still not as flexible as the ObjC method.
The best way to see what I'm talking about is to download the source from the loaders page linked to above, and look at MenuScreenRUBELayer.cpp which is a simple example of extending BasicRUBELayer. The important point is in the constructor, where the string name to be used in RUBE is matched with a function in the class. In that example, I have made the function switch the scene, so even if we can't have the more flexible method of simply setting the class name in RUBE directly, it's not the end of the world.
Re: ButtonRUBELayer
awesome, i should have waited
Have you tried this on Android? Wondering how i can support multiple screen sizes with RUBE base menu scenes...maybe use same approach as your iOS by displaying different aspect ratio in RUBE. By the way how can i easily add more aspect ratio lines to the RUBE scene?
Thanks!

Thanks!
Re: ButtonRUBELayer
Trying for Android right now
Finally managed to get the damn thing to build and run HelloWorld, now to try setting up the RUBE things...
The screens are set up so that the height will always be a specific size in the physics world, eg. 6.4 in the examples in the sample project. This was chosen to match a height of 640 pixels for iPhone retina and iPhone5, but it turned that this didn't really matter. You can set something else in the initialWorldScale function of ButtonRUBELayer (or override that function in your subclass). If you only have static menus then the scale you choose will be completely irrelevant, but if you want some dynamic bodies moving about then the usual advice of trying to keep things around 1 unit in size is applicable.
By the way, during the development of DHS we began to want a slightly different layout to fit each of the screen aspects better, so we eventually split those menu scenes into separate scenes for each aspect, and load the relevant one for the current device. The main reason is that we wanted some buttons to be in the corner of the screen, but if only one scene is used for all devices, the position of the buttons must be placed to fit the smallest ratio (iPad) to make sure the button is fully visible on the screen. This works fine but looks a bit strange on iPhone5 where the screen is much wider.
To add more lines you can just select one of the existing fixtures and duplicate it, then scale in the x-dimension (hit S,X). However, it might be better to set the position of each vertex in the properties panel to make sure they are exactly where you want them. Come to think of it, I made a script so that I could quickly add these frames to a scene, which you can find here: viewtopic.php?f=9&t=114

The screens are set up so that the height will always be a specific size in the physics world, eg. 6.4 in the examples in the sample project. This was chosen to match a height of 640 pixels for iPhone retina and iPhone5, but it turned that this didn't really matter. You can set something else in the initialWorldScale function of ButtonRUBELayer (or override that function in your subclass). If you only have static menus then the scale you choose will be completely irrelevant, but if you want some dynamic bodies moving about then the usual advice of trying to keep things around 1 unit in size is applicable.
By the way, during the development of DHS we began to want a slightly different layout to fit each of the screen aspects better, so we eventually split those menu scenes into separate scenes for each aspect, and load the relevant one for the current device. The main reason is that we wanted some buttons to be in the corner of the screen, but if only one scene is used for all devices, the position of the buttons must be placed to fit the smallest ratio (iPad) to make sure the button is fully visible on the screen. This works fine but looks a bit strange on iPhone5 where the screen is much wider.
To add more lines you can just select one of the existing fixtures and duplicate it, then scale in the x-dimension (hit S,X). However, it might be better to set the position of each vertex in the properties panel to make sure they are exactly where you want them. Come to think of it, I made a script so that I could quickly add these frames to a scene, which you can find here: viewtopic.php?f=9&t=114
Re: ButtonRUBELayer
I got it working for Android, looks good!
Hoping for one scene for screen aspects, but having multiple wont be to bad.
Thanks for the script!
Hoping for one scene for screen aspects, but having multiple wont be to bad.
Thanks for the script!