zoukankan      html  css  js  c++  java
  • Cocos2d-x之绘制点

    Cocos2d-x之绘制点

    自定义的方法

    Point.h

     1 //
     2 //  Points.h
     3 //  L01DrawingAPI
     4 //
     5 //  Created by Mac OS 10.9.3 on 15-3-30.
     6 //
     7 //
     8 
     9 #ifndef __L01DrawingAPI__Points__
    10 #define __L01DrawingAPI__Points__
    11 
    12 #include <iostream>
    13 #include <cocos2d.h>
    14 
    15 USING_NS_CC;
    16 
    17 namespace bobo {
    18     
    19     class Points:public Node{
    20         
    21     public:
    22         
    23         virtual bool init();
    24         virtual void draw();
    25         CREATE_FUNC(Points);
    26         
    27         
    28     };
    29 }
    30 
    31 #endif /* defined(__L01DrawingAPI__Points__) */

    Point.cpp

     1 //
     2 //  Points.cpp
     3 //  L01DrawingAPI
     4 //
     5 //  Created by Mac OS 10.9.3 on 15-3-30.
     6 //
     7 //
     8 
     9 #include "Points.h"
    10 
    11 namespace bobo {
    12     
    13     bool Points::init(){
    14         
    15         return true;
    16     }
    17     
    18     void Points::draw(){
    19         
    20         //绘制一个颜色随机的50*50的点
    21         for (int y = 0; y < 50; y ++) {
    22             for (int x = 0; x < 50; x ++) {
    23                 DrawPrimitives::setDrawColor4B(rand() % 256, rand() % 256, rand() % 256, 255);
    24                 DrawPrimitives::drawPoint(Point(x, y));
    25             }
    26         }
    27         
    28     }
    29 }

    bool HelloWorld::init()

      auto points = bobo::Points::create();

        points->setPosition(Point(500, 300));

        addChild(points);

  • 相关阅读:
    回顾C#3.0新特性(3)
    第五周作业
    第六周基础作业
    第三周syh
    基础作业
    第七周作业
    2019年春季学期第四周作业
    第八周作业
    .Net 反射
    C#中SqlParameter
  • 原文地址:https://www.cnblogs.com/dudu580231/p/4379583.html
Copyright © 2011-2022 走看看