Cocos2d-x3.2 draw line

Source: Internet
Author: User

# Include "cocos2d. H "using_ns_cc; Class gamescene: Public cocos2d: layer {public: static cocos2d: Scene * createscene (); Virtual bool Init (); void menucallback (ref * psender ); create_func (gamescene); // reload the draw method virtual void draw (Renderer * Renderer, const mat4 & transform, uint32_t flags) override; protected: // custom draw implements void ondraw (const cocos2d: mat4 & transform, bool transformupdated); cocos2d: customcommand _ customcommand; private: // note that the auto keyword size cannot be used; sprite * sprite ;};




// Created by jacedy on 14-8-11. # include "gamescene. H "using_ns_cc; cocos2d: Scene * gamescene: createscene () {auto scene = scene: Create (); // create a scenario auto layer = gamescene :: create (); // create a layer scene-> addchild (layer); Return scene;} // initialize the current layer bool gamescene: Init () {If (! Layer: Init () // initialize the parent class return false; // obtain the screen size = Director: getinstance ()-> getvisiblesize (); // auto size = Director: getinstance ()-> getwinsize (); Return true;} void gamescene: Draw (Renderer * Renderer, const mat4 & transform, uint32_t flags) {_ customcommand. init (_ globalzorder); _ customcommand. func = cc_callback_0 (gamescene: ondraw, this, transform, flags); Renderer-> addcommand (& _ customcommand);} voi D gamescene: ondraw (const cocos2d: mat4 & transform, bool transformupdated) {// use stack cache Director * Director = Director: getinstance (); // ccassert (nullptr! = Director, "director is null when setting matrix stack"); Director-> pushmatrix (matrix_stack_type: matrix_stack_modelview); Director-> loadmatrix (matrix_stack_type: matrix_stack_modelview, transform ); check_gl_error_debug (); // draw the border drawprimitives: setdrawcolor4b (255,255,255,255); gllinewidth (10); vec2 vertices [] = {vec2 (100,100), vec2 (300,100 ), vec2 (300,300), vec2 (100,300)}; drawprimitives: drawpoly (vertices, 4, true); check_gl_error_debug (); // stops plotting and releases Director-> popmatrix (matrix_stack_type:: matrix_stack_modelview);} void gamescene: menucallback (ref * psender ){}


Cocos2d-x3.2 draw line

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.