I want to update 50 “Circle sprites” (sprite with a circle in graphics object) on a timer event. Each circle’s radius and position is calculated with a formula based on preloaded xml data.
Existing Class structure:
GameBoard (Sprite)
- DataXML (Object)
- updateBubbles ()
- calculateRadius ()
- GraphicsContainer (Sprite)
– Bubble1 (Sprite)
– Bubble2 (Sprite)
To minimize function calls etc, how do I update the Bubble sprites within the graphics container? Where do I store the data and to which object does the method “calculateRadius” belong? Could they perhaps be static and shared among the Bubble sprites?
What are my options?
(Preferably something better than the cross-referencing outlined below)
GameBoard.as
function updateBubbles () {
for (i=0 ; i < graphicsContainer.numChildren ; i++){
bubble = graphicsContainer.getChildAt(i)
bubble.update()
}
}
Bubble.as
function update() {
radius = GameBoard.calculateRadius(this ... )
}