ChilliSource icon indicating copy to clipboard operation
ChilliSource copied to clipboard

[Feature Request] Utility Classes

Open KamiGrave opened this issue 8 years ago • 0 comments

I've not yet seen anything to make Chilli Source a bit easier to use. Even the basics such as making a sprite require about 6 different calls and the code is not simple. This is the code I'm currently using to create my sprites (WIP Code, I know in_shareMaterial is never used): ` CS::SpriteComponentUPtr CreateSpriteFromSpriteSheet(const std::string& in_fileName, const std::string& in_spriteSheetName, const std::string& in_frameName, bool in_shareMaterial) { CS::IResourceOptionsCSPtrCS::Texture textureOptions = CS::IResourceOptionsCSPtrCS::Texture(new CS::TextureResourceOptions(false, CS::TextureFilterMode::k_nearest, CS::TextureWrapMode::k_repeat, CS::TextureWrapMode::k_repeat));

	CS::TextureCSPtr texture = CS::Application::Get()->GetResourcePool()->LoadResource<CS::Texture>(CS::StorageLocation::k_package, in_fileName, textureOptions);

	CS::TextureAtlasCSPtr cardAtlas = CS::Application::Get()->GetResourcePool()->LoadResource<CS::TextureAtlas>(CS::StorageLocation::k_package, in_spriteSheetName);

	CS::MaterialCSPtr material = MaterialUtils::getMaterialWithName(in_fileName, texture);

	CS::TextureAtlas::Frame frame = cardAtlas->GetFrame(in_frameName);

	return CS::SpriteComponentUPtr(new CS::SpriteComponent(material, cardAtlas, in_frameName, frame.m_croppedSize, CS::SizePolicy::k_usePreferredSize));
}`

I've had quite a bit of experience with this engine, so I know how to build a sprite now but compared to other engines having to load a texture, an atlas, create a material (that must be unique no less, my material utils has a way around that) and get the texture atlas frame to get the sizing right, is just far too much work to do for a single sprite. I would imagine that most people would write a utility similar to the one above to handle loading sprites, but I would request that Chilli Source provide some helper functions that make the most basic features easier to use.

KamiGrave avatar Jun 21 '17 20:06 KamiGrave