Android游戏开发学习之引擎用法实例详解

2019-12-10 20:00:43于丽

(6)颜色工具类ColorUtil

 

 
  1. package box2d.bheap;   public class ColorUtil {  
  2. static int[][] result=   {  
  3. {56,225,254},   {41,246,239},  
  4. {34,244,197},   {44,241,161},  
  5. {65,239,106},   {45,238,59},  
  6. {73,244,51},   {99,233,58},  
  7. {129,243,34},   {142,245,44},  
  8. {187,243,32},   {232,250,28},  
  9. {242,230,46},   {248,196,51},  
  10. {244,125,31},   {247,88,46},  
  11. {249,70,40},   {249,70,40},  
  12. {248,48,48},   {250,30,30},  
  13. {252,15,15},   {255,0,0},  
  14. };   public static int getColor(int index)  
  15. {   int[] rgb=result[index%result.length];  
  16. int result=0xff000000;   result=result|(rgb[0]<<16);  
  17. result=result|(rgb[1]<<8);   result=result|(rgb[2]);  
  18. return result;   }  

(7)主控制类MyBox2dActivity

 

 
  1. package box2d.bheap;   import java.util.ArrayList;  
  2. import java.util.Random;   import org.jbox2d.collision.AABB;  
  3. import org.jbox2d.common.Vec2;   import org.jbox2d.dynamics.World;