Пример #1
0
bool ImageAlphaLut::initWithFile(const std::string file)
{
//    // 打开文件
//    auto fp = fopen(FileUtils::getInstance()->fullPathForFilename(file).c_str(), "rb");
//    // 获取文件大小
//    fseek(fp, 0, SEEK_END);
//    long fs = ftell(fp);
//    rewind(fp);

    auto data = FileUtils::getInstance()->getDataFromFile(file);

    auto buff = data.getBytes();
    data.fastSet(nullptr, 0);

    // 分配文件头信息 BUFF
//    unsigned char * buff = (unsigned char *)malloc(fs);
    // 读取文件头信息
//    size_t rs = fread(buff, sizeof(unsigned char), fs, fp);

//    CCASSERT(rs == fs, "Read file info error");

//    fclose(fp);
    int * p = (int *)buff;

    bool b = initWithBuff(++p);

    CC_SAFE_FREE(buff);

    return b;
}
Пример #2
0
void HudPanel::selectedBuffEvent(Ref *pSender, ListView::EventType type)
{
	switch (type)
	{
	case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_START:
		{
			ListView* listView = static_cast<ListView*>(pSender);
			CC_UNUSED_PARAM(listView);
			CCLOG("select child start index = %ld", listView->getCurSelectedIndex());
			//auto tag = listView->getItem(listView->getCurSelectedIndex())->getTag();
			//auto endStatUnit = _endStatsUnit.at(listView->getCurSelectedIndex());
			break;
		}
	case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_END:
		{
			ListView* listView = static_cast<ListView*>(pSender);
			CC_UNUSED_PARAM(listView);
			CCLOG("select child end index = %ld", listView->getCurSelectedIndex());
			auto buffUnit = static_cast<BuffUnit*>(listView->getItem(listView->getCurSelectedIndex()));
			
			auto buffPan = BuffPanel::create("buff");
			buffPan->initWithBuff(buffUnit->getBuff());
			PopPanel::getInstance()->addPanel(buffPan, 2);
			break;
		}
	default:
		break;
	}
}
Пример #3
0
ImageAlphaLut* ImageAlphaLut::createWithBuff(const void *buff)
{

    auto ret = new ImageAlphaLut();
    if (ret && ret->initWithBuff(buff))
    {
        ret->autorelease();
    }
    else
    {
        delete ret;
        ret = nullptr;
    }
    return ret;
}