bool LuaTouchEventManager::init() { _running = true; auto size = Director::getInstance()->getWinSize(); return initWithSize(size); }
FlipY3D* FlipY3D::clone() const { // no copy constructor auto a = new FlipY3D(); a->initWithSize(_gridSize, _duration); a->autorelease(); return a; }
// ---------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------- void ProgrammaticTexture2D::reload( CallbackPtr ptr, FileManager::PlatformPolicy policy ) { if (name_ == NO_TEXTURE) { // rebuild! initWithSize(width_, height_, settings_.getColorspace()); setData(imageBuffer_); } if (ptr) { TextureLoadedCallbackParameters params( fileName_, ResultCode_OK ); ptr->invoke((void*)¶ms); } }
bool GridBase::initWithSize(const cocos2d::Size &gridSize, const cocos2d::Rect &rect) { Director *director = Director::getInstance(); Size s = director->getWinSizeInPixels(); auto POTWide = ccNextPOT((unsigned int)s.width); auto POTHigh = ccNextPOT((unsigned int)s.height); // we only use rgba8888 Texture2D::PixelFormat format = Texture2D::PixelFormat::RGBA8888; auto dataLen = POTWide * POTHigh * 4; void *data = calloc(dataLen, 1); if (! data) { CCLOG("cocos2d: Grid: not enough memory."); this->release(); return false; } Texture2D *texture = new (std::nothrow) Texture2D(); texture->initWithData(data, dataLen, format, POTWide, POTHigh, s); free(data); if (! texture) { CCLOG("cocos2d: Grid: error creating texture"); return false; } initWithSize(gridSize, texture, false, rect); texture->release(); return true; }
bool CCGridBase::initWithSize(ccGridSize gridSize) { CCDirector *pDirector = CCDirector::sharedDirector(); CGSize s = pDirector->getWinSizeInPixels(); unsigned int POTWide = ccNextPOT((unsigned int)s.width); unsigned int POTHigh = ccNextPOT((unsigned int)s.height); // on mac, it use kCCTexture2DPixelFormat_RGBA8888 CCTexture2DPixelFormat format = kCCTexture2DPixelFormat_RGBA8888; void *data = calloc((int)(POTWide * POTHigh * 4), 1); if (! data) { CCLOG("cocos2d: CCGrid: not enough memory."); this->release(); return false; } CCTexture2D *pTexture = new CCTexture2D(); pTexture->initWithData(data, format, POTWide, POTHigh, s); free(data); if (! pTexture) { CCLOG("cocos2d: CCGrid: error creating texture"); delete this; return false; } initWithSize(gridSize, pTexture, false); pTexture->release(); return true; }
bool CCGridBase::initWithSize(const ccGridSize& gridSize) { CCDirector *pDirector = CCDirector::sharedDirector(); CCSize s = pDirector->getWinSizeInPixels(); unsigned int POTWide = (unsigned int) s.width; unsigned int POTHigh = (unsigned int) s.height; bool needPOT = !g_Render->isRenderTargetNPOTSupported(); if (needPOT) { POTWide = PixelFormat::calcNextPot(POTWide); POTHigh = PixelFormat::calcNextPot(POTHigh); } // we only use rgba8888 CCTexture2DPixelFormat format = kCCTexture2DPixelFormat_RGBA8888; CCTexture2D *pTexture = new CCTexture2D(); if (! pTexture) { CCLOG("cocos2d: CCGrid: error creating texture"); delete this; return false; } pTexture->initWithTexture( new GLESTexture(POTWide, POTHigh, CCTexture2D::ToNitPixelFormat(format, false))); initWithSize(gridSize, pTexture, false); pTexture->release(); return true; }
bool CCGridBase::initWithSize(const CCSize& gridSize) { CCDirector *pDirector = CCDirector::sharedDirector(); CCSize s = pDirector->getWinSizeInPixels(); unsigned long POTWide = CCUtils::nextPOT((unsigned int)s.width); unsigned long POTHigh = CCUtils::nextPOT((unsigned int)s.height); // we only use rgba8888 CCTexture2DPixelFormat format = kCCTexture2DPixelFormat_RGBA8888; void *data = calloc((int)(POTWide * POTHigh * 4), 1); if (! data) { CCLOG("cocos2d: CCGrid: not enough memory."); CC_SAFE_RELEASE(this); return false; } CCTexture2D *pTexture = new CCTexture2D(); pTexture->initWithData(data, format, POTWide, POTHigh, s); free(data); if (! pTexture) { CCLOG("cocos2d: CCGrid: error creating texture"); return false; } initWithSize(gridSize, pTexture, false); CC_SAFE_RELEASE(pTexture); return true; }
bool GridBase::initWithSize(const Size& gridSize) { Director *pDirector = Director::getInstance(); Size s = pDirector->getWinSizeInPixels(); unsigned long POTWide = ccNextPOT((unsigned int)s.width); unsigned long POTHigh = ccNextPOT((unsigned int)s.height); // we only use rgba8888 Texture2DPixelFormat format = kTexture2DPixelFormat_RGBA8888; void *data = calloc((int)(POTWide * POTHigh * 4), 1); if (! data) { CCLOG("cocos2d: Grid: not enough memory."); this->release(); return false; } Texture2D *pTexture = new Texture2D(); pTexture->initWithData(data, format, POTWide, POTHigh, s); free(data); if (! pTexture) { CCLOG("cocos2d: Grid: error creating texture"); return false; } initWithSize(gridSize, pTexture, false); pTexture->release(); return true; }
bool GridBase::initWithSize(const Size& gridSize) { return initWithSize(gridSize, Rect::ZERO); }
bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool flipped) { return initWithSize(gridSize, texture, flipped, Rect::ZERO); }
bool Scene::init() { auto size = Director::getInstance()->getWinSize(); return initWithSize(size); }
void init(DeviceList* const list) { initWithSize(list, 16); }
bool CCRectNode::initWithRect(const CCRect& tRect, const ccColor4F& tColor, bool bFill) { setPosition(tRect.origin); return initWithSize(tRect.size, tColor, bFill); }
StaticArray(index_t size) : _size(0), _data(0) { initWithSize(size); }
void initWithData(const T* array, index_t size) { initWithSize(size); for (index_t i = 0; i < size; ++i) _data[i] = array[i]; }