Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I were you I would worry more on how to efficiently do the Math rather than passing the data around because there you loose a big amount of time.</p> <p>My advice on this would be:</p> <p>Do all the calculation on the BubbleContainer (or anywhere else, but in one place rather than inside each object)</p> <ul> <li><p>Precalc things like Math.PI/180</p></li> <li><p>Precalc 2 arrays/vectors of sine and cosine values.(It's faster to get<br> them from an array rather than<br> calling Math.sin/Math.cos each time )</p></li> <li><p>Pass the result to the Bubble sprite in 1 call ( as Cristi pointed out )</p></li> <li><p>Create a function that accepts input parameters , does <strong>all</strong> the math and returns the answer.</p> <p>For each set of input( on each cal of this function ):</p> <p>First see if the answer was calculated before, if it was retrieve it from the answer dictionary.</p> <p>if not calculate it and add it to the answer dictionary.</p> <p>Create an entry in a dictionary that has the input values as the key and the answer as the value. This way you are creating a cache of answers. For complicated,recurring calculations with a relatively small number of input parameters(as in your situation) it's faster to retrieve answer that you already calculated from a dictionary rather than doing the calculation again. If you'll use an array instead of a dictionary I believe it's going to be even faster..</p></li> </ul> <p>Quick example, not optimized, just to give you an idea:</p> <pre><code>function multiply(x:int,y:int):int{ var retValue:int; var key:String=String(x)+String(y); if (answers[key]){ retValue=answers[key];} else{ retValue=x*y; answers[key]=retValue;} return retValue; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload