作为一名初学者想通过写博客来记录自己学习的过程,第一个例程是一个简单的拼图游戏。
1.头文件CuttingPhotos.h
<span style="font-size:18px;">#pragma once
#include "cocos2d.h"
USING_NS_CC;
class CuttingPhotos:public Layer
{
public:
CuttingPhotos();
~CuttingPhotos();
//行数和列数
static CuttingPhotos*create(const char*photo, unsigned int rows = 3, unsigned int columns = 3);
protected:
unsigned int _row;//行数
unsigned int _column;//列数
unsigned int _sliceWidth;//格子宽度
unsigned int _sliceHeight;//格子高度
std::vector<std::vector<Sprite*>> _slices;//二维数组存储我们的切片;
virtual bool initWithPhoto(const char*photo, unsigned int rows , unsigned i