kestrelm / creature_cocos2dx Goto Github PK
View Code? Open in Web Editor NEWCocos2d-x Runtimes for Creature
License: Apache License 2.0
Cocos2d-x Runtimes for Creature
License: Apache License 2.0
I'm trying to get a simple test working using Creature Pack on Cocos2d-x runtime on a Linux machine using GCC 5.3. Unfortunately, it throws std::bad_cast.
Adapted code from: http://www.kestrelmoon.com/creaturedocs/Game_Engine_Runtimes_And_Integration/Cocos2d-x_Runtimes%20.html
// CreaturePack Demo, shows you how to load a Creature Pack character in cocos2d-x
// First, create the CreaturePackLoader
auto packFilename = CCFileUtils::getInstance()->fullPathForFilename("naser_character_data.creature_pack");
auto packLoader = CreaturePackRenderer::createPackLoader(packFilename);
// Now create the renderer for CreaturePack
auto packRenderer =
CreaturePackRenderer::Renderer::create(
packLoader.get(),
CCTextureCache::getInstance()->addImage("naser_character_img.png"));
packRenderer->setScale(120.0f);
packRenderer->setPosition(Vec2(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y));
this->addChild(packRenderer, 1);
// Set Animation settings
auto playerObj = packRenderer->getPlayerObj();
playerObj->blendToAnimation("idle", 0.2f);
playerObj->isLooping = true;
playerObj->isPlaying = true;
packRenderer->setPlaybackSpeed(30.0f);
Runtime output from Qt Creator:
Starting /home/babaei/NaserCompany/build-NaserTest-GCC_X64-Default/bin/MyGame...
Ready for GLSL
Ready for OpenGL 2.0
libpng warning: iCCP: known incorrect sRGB profile
terminate called after throwing an instance of 'std::bad_cast'
what(): std::bad_cast
The program has unexpectedly finished.
/home/babaei/NaserCompany/build-NaserTest-GCC_X64-Default/bin/MyGame crashed.
I managed to track it down to line 210 from CreaturePackRenderer.cpp:
// Helper function to create a CreaturePackLoader from a full filepath
std::shared_ptr<CreaturePackLoader> createPackLoader(const std::string & fullpath)
{
// open the file:
std::basic_ifstream<uint8_t> file(fullpath, std::ios::binary);
// read the data:
auto raw_bytes = std::vector<uint8_t>((std::istreambuf_iterator<uint8_t>(file)),
std::istreambuf_iterator<uint8_t>());
return std::shared_ptr<CreaturePackLoader>(new CreaturePackLoader(raw_bytes));
}
It's probably std::istreambuf_iterator which throws and I don't have a clue why. Tried this on Cocos2d-x 3.14.1.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.