引用:
[图片] pic3.jpg
[图片] pic4.jpg
[代码] [Java]代码
01 | public class Player extends AnimatedSprite { |
02 | ... |
03 | @Override |
04 | protected void onManagedUpdate( final float pSecondsElapsed) { |
05 | super .onManagedUpdate(pSecondsElapsed); |
06 | onBeforePositionChanged(); |
07 | } |
08 |
09 | private boolean onBeforePositionChanged(){ |
10 | |
11 | //speed up |
12 | if (frameCount < 2 ){ |
13 | frameCount++; |
14 | return true ; |
15 | } |
16 | frameCount = 0 ; |
17 | |
18 | int enemyListSize = levelController.getEnemyList().size(); |
19 | for ( int i = 0 ; i < enemyListSize; i++) |
20 | if ( this .collidesWith(levelController.getEnemyList().get(i))) |
21 | { |
22 | levelController.callbackCollisionEnemy(); |
23 | return false ; |
24 | } |
25 | for ( int i = 0 ; i < levelController.getGoodsList().size(); i++) |
26 | if ( this .collidesWith(levelController.getGoodsList().get(i))) |
27 | { |
28 | levelController.callbackCollisionGoods(i); |
29 | return false ; |
30 | } |
31 |
32 | for ( int i = 0 ; i < levelController.getEndPointList().size(); i++) |
33 | if ( this .collidesWith(levelController.getEndPointList().get(i))) |
34 | { |
35 | levelController.callbackCollisionWithEndPoint(); |
36 | return false ; |
37 | } |
38 | return true ; |
39 | } |
40 | ... |
41 | } |