Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. //
  2. // MyLayerColor.h
  3. //
  4. #include "cocos2d.h"
  5.  
  6. USING_NS_CC;
  7. class MyLayerColor : public cocos2d::LayerColor
  8. {
  9. public:
  10. static MyLayerColor *create(const Color4B& color, float width, float height);
  11.  
  12. virtual bool initWithColor(const cocos2d::Color4B &color, float width, float height);
  13. };
  14. #endif /* defined(__Shooter__MyLayerColor__) */
  15.  
  16.  
  17.  
  18. //
  19. // MyLayerColor.cpp
  20. //
  21. #include "MyLayerColor.h"
  22.  
  23.  
  24. MyLayerColor * MyLayerColor::create(const Color4B& color, float width, float height)
  25. {
  26. MyLayerColor * layer = new (std::nothrow) MyLayerColor();
  27. if( layer && layer->initWithColor(color, width, height))
  28. {
  29.  
  30. layer->autorelease();
  31. return layer;
  32. }
  33.  
  34. CC_SAFE_DELETE(layer);
  35. return nullptr;
  36. }
  37.  
  38. bool MyLayerColor::initWithColor(const cocos2d::Color4B &color, float width, float height)
  39. {
  40. //////////////////////////////
  41. // 1. super init first
  42. bool isOk = LayerColor::initWithColor(color, width, height);
  43. if (isOk == false)
  44. {
  45. return false;
  46. }
  47.  
  48. return true;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement