Bitmap Handler Actor "injecting" to View components

rivella50's Avatar

rivella50

16 Jul, 2011 02:34 PM

Hi there,

i'm implementing a Game for mobile devices with Flash Builder 4.5.1 using Robotlegs.
The images are included (per DPI) in one image sheet png file and loaded in StartupCommand into a Bitmap Sheet Handler
which extends Actor.
Since all view components need to show image assets this Sheet Handler is then injected into all Mediators that exist.
Now my question: How will all my view (sub) components get access to that sheet handler so that they can get copies of
the bitmaps they need to show ?
Injection is not possible, so i could
- pass the reference of the Sheet Handler in Mediator to all view (also sub) components where they take what they need - pass the reference only to the view that is mapped to the mediator in mediatorMap where that view passes it itself to the sub view components - get all needed Bitmaps in Mediator and pass them to the view components

All of these approaches are not very elegant in my opinion. Are there other options ?
Perhaps not treating the Bitmap Sheet Handler as an Actor but as a normal Singleton and let the view components directly
access it without any Mediator in between ?

I'm curious about your thoughts. Thank you.
Bests
valley

  1. Support Staff 2 Posted by Stray on 21 Jul, 2011 02:53 PM

    Stray's Avatar

    Hi, Sorry for the delay in this question appearing - for some reason it was marked as spam. Hopefully you'll get some responses now!

    My own preferred strategy for this is to have a singleton 'viewBitmapSheetManager' that is injected into mediators. in onRegister, the mediator passes its view to the manager class. The manager then provides the view with the bitmaps (or skin in my case) and the manager itself keeps track of which views are already processed so that they don't get re-processed if it's not required.

    How you want to deal with composite views is up to you - but it'd make sure that logic was in this dedicated class and not your mediator or your view.

    hth,

    Stray

  2. Ondina D.F. closed this discussion on 02 Nov, 2011 05:35 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac