Search code examples
androidcocos2d-android

How to crop an image in Cocos2d


I am new to this Cocos2d. i am developing a Tetris type of game. I want to crop an image into small blocks. All i know about this thing is that in iPhone a method called CGImageCreateWithImageInRect is used. Is there any method of this kind is available in android cocos2d or not?


Solution

  • I have created bitmap of that image then crop that bitmap using these code.

    Bitmap bmp=BitmapFactory.decodeResource(getResources(), R.drawable.xyz);
    
    resizedbitmap1=Bitmap.createBitmap(bmp, 0,0,yourwidth, yourheight);
    

    then converted this bitmap to sprite and this way i solved my issue.