Slick Forums

Discuss the Slick 2D Library
It is currently Thu Jun 01, 2023 10:27 pm

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: How far is too far?
PostPosted: Sun Feb 16, 2014 10:55 pm 

Joined: Sun Feb 16, 2014 10:31 pm
Posts: 1
I've been slowly converting my hobby game to use Artemis. It has greatly reduced the number of objects and interactions from my previous MVC design.

I still find that I'm passing multiple Camera and SpriteBatch objects to various system constructors. I would really like to wrap these objects in components of artificial entities, but I don't understand the proper way to have a system process multiple non-related entities.

For instance, my RenderSystem would need to call Aspect.getAspectForOne() for my Batch, Camera and Sprite classes. Those entities would be delivered to process() in a random order. What is the proper way to handle this?

I may be going too far. Passing Camera and SpriteBatch around isn't too bad. It just seems impure now that I've discovered how flexible Artemis is.

Thank you,


 Post subject: Re: How far is too far?
PostPosted: Thu Feb 27, 2014 4:49 am 

Joined: Mon Sep 30, 2013 12:48 pm
Posts: 6
Hey SweeterThan,

I was facing the same problem in my game, so I created an entity which had a component containing a Camera, a SpriteBatch and some other stuff. If you are using the original artemis or artemis-odb, you can then use GroupManager to tag this entity and retrieve it when needed.

Alternatively, if you decide to use gdx-artemis (shameless plug) you can take advantage of a SingletonComponentManager. It basically allows you to store and retrieve a specific component from a singleton entry in the system. This way, you can process this entry as normal using EntitySystems or you can retrieve specific components of this entry in another System that is, say, responsible for drawing your sprites.

Either way, I think the best way to access those kind of resources is through a manager rather in a standard EntitySystem approach.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group