博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Cocos2d-x之绘制点
阅读量:7060 次
发布时间:2019-06-28

本文共 1334 字,大约阅读时间需要 4 分钟。

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 
13 #include
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);

转载于:https://www.cnblogs.com/dudu580231/p/4379583.html

你可能感兴趣的文章
java线程
查看>>
清空文件内容
查看>>
第九周学习总结
查看>>
word2tex之类的问题
查看>>
级连查询与更新
查看>>
Maven报错:ArtifactdescriptorException: failed to read artifact for xxxxxx
查看>>
C# API 调用格式和参数类型
查看>>
无法删除MySql数据库,报错1010 error dropping
查看>>
Android application使用总结
查看>>
硬币问题
查看>>
鼠标悬停图片移动的效果
查看>>
YII2操作mongodb笔记(转)
查看>>
javaScript 比较数字大小
查看>>
从汇编来看c语言之指针
查看>>
sqlserver查询表索引
查看>>
JavaScript 基础知识系列:数据类型及slice(8,-1)
查看>>
2018.3.31——(4)句子
查看>>
js call
查看>>
【记录一个问题】linux + opencv + gpu视频解码,好不容易编译通过,运行又coredump了...
查看>>
layui 表格组件不能访问连续的属性的解决办法
查看>>