cocos2d-x V3.x不规则按钮-续篇
by
Galoisplusplus
- 日 25 1月 2015
Tags
#tech
#CS
#cocos2d-x
#cocos
#cocos2d
#button
#widget
#irregular
#不规则按钮
#UI
#按钮
#opengl
#gl
#OpenGL ES
#游戏开发
#手游开发
#mobile game
#game devolopment
之前曾经在cocos2d-x V3.x不规则按钮探讨过在cocos2d-x 3.x版本实现不规则按钮的方法,后来本渣又琢磨了下仿照RenderTexture类调用OpenGL ES API来获取图片像素信息的方式。这种方式由于按钮图片的Texture已在内存中,且不需要解析图片文件格式,因此相比之前用Image::initWithImageFile还是要快一些的。
重写的loadNormalTransparentInfo函数如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
完整代码请参考: cocos2d-x-irregular-button