/** creates a fullscreen black layer * /static layercolor* create (); /** creates a Layer with color, width and height in Points * /static Layercolor * Create (const color4b& color, GLf Loat width, glfloat height); /** creates a Layer with color. Width and height are the window size. * /Static Layercolor * Create (const color4b& color); Cc_constructor_access: layercolor (); Virtual ~layercolor (); BOOL Init (); BOOL Initwithcolor (const color4b& color, glfloat width, glfloat height); BOOL Initwithcolor (const color4b& color);
Similar to Layercolor, but it needs to specify two colors and the direction of the gradient when it is initialized.
The number of the starting color. The end parameter is the ending color, and V is the direction vector. layergradient The method of creation and initialization method as seen below:
/** creates a fullscreen black layer */static layergradient* create (); /** creates a full-screen Layer with a gradient between start and end. */static layergradient* Create (const color4b& start, const color4b& end); /** creates a full-screen Layer with a gradient between start and end in the direction of V. * * static layergradient* C reate (const color4b& Start, const color4b& end, const point& v); Cc_constructor_access:layergradient (); Virtual ~layergradient (); virtual BOOL init (); /** initializes the Layer with a gradient between start and end. * @js init * @lua init * */BOOL Initwithcolor (const color4b& Start, const color4b& end); /** initializes the Layer with a gradient between start and end in the direction of V. * @js init * @lua init * */BOOL Initwithcolor (const color4b& Start, const color4b& end, const point& V);
after the color block is created, you can also change the color block size by following the methods listed below:
/** change width in points*/ void Changewidth (glfloat w); /** change height in points*/ void Changeheight (Glfloat h); /** change width and height in Points @since v0.8 * /void Changewidthandheight (glfloat W, glfloat h);
Menu : Game Menus Menus are an integral part of the game.
in Cocos2d-x, the menu is made up of two parts, each of which is the menu item and itself. MenuItem represents a menu item. Each menu item is a separate button. It defines the visual representation and response action of the menu, which is the menu, which organizes the items into one and adds them to the scene. Transforms the touch events of the screen into individual menu items.
the creation of a menu item usually requires a normal state, a pressed state, a clicked response, and a response method. Below we take a picture menu item as an example to create a dish item, related code such as the following:
Create a "Close" menu item with close icon, it's an auto release object. Menuitemimage *pcloseitem = menuitemimage::create ( "closenormal.png",//Picture "Closeselected.png" in normal state,// Press status picture Cc_callback_1 (Helloworld::menuclosecallback, this));//Response function and Object cc_break_if (! Pcloseitem);
callback to the Menuclosecallback function when the button is clicked:Run end game logic: Director::getinstance ()->end ();
Shimen Main Friendship tips:more use of the features provided by the engine, will save a lot of time and energy!
17, COCOS2DX 3.0 game development to find small three's built-in frequently used layer: Three Musketeers layercolor, Layergradient, Menu