[Solved] cocos2dx equivalent of Android canvas's BitmapShader

[Solved] cocos2dx equivalent of Android canvas's BitmapShader
0.0 0


Im new to cocos2dx and have been trying to port a game from Android (using canvas) to cocos2dx. I use the following code to create a tile using a png in android.

//create bitmap shader
Bitmap mBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.rock_texture); BitmapShader mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);

//add to paint
Paint mPaint = new Paint(); mPaint.setShader(mBitmapShader);

//draw on canvas
canvas.save(); canvas.clipPath(mPath); canvas.drawRect(0, 0, w, h, mPaint); canvas.restore();

Bitmap Shader doc http://developer.android.com/reference/android/graphics/BitmapShader.html
How can I do the same thing in cocos2dx?

PRkit for cocos2dx -