Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Utility Classes #20

Open
KamiGrave opened this issue Jun 21, 2017 · 0 comments
Open

[Feature Request] Utility Classes #20

KamiGrave opened this issue Jun 21, 2017 · 0 comments

Comments

@KamiGrave
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant