Example #1
0
  public Bullets(Context context, float x, float y, boolean autoAdd, int type_direction) {
    super(x, y, autoAdd);
    // TODO Auto-generated constructor stub
    //		setBitmapAndAutoChangeWH(BitmapUtil.hand);
    setBitmapAndFrameWH(
        BitmapUtil.hand, BitmapUtil.hand.getWidth() / 7, BitmapUtil.hand.getHeight() / 2);
    addActionFPSFrame(
        HandAnimaton.Move.getName(),
        new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13},
        HandAnimaton.Move.getFramesTime());

    //		setX(x - w/2);
    this.type_direction = type_direction;

    //		if(type_direction == TYPE_TWO_HAND_LEFT_UP || type_direction == TYPE_TWO_HAND_RIGHT_UP){
    //			reflectCounter++;
    //		}
    if (type_direction == TYPE_TWO_HAND_LEFT_UP || type_direction == TYPE_TWO_HAND_RIGHT_UP) {
      if (type == Top) {
        type = Down;
      } else {
        type = Top;
      }
      limit = CommonUtil.cat_bg_height;
    }
    this.context = context;
    initCollisiontRectF();
    initMove();
  }
Example #2
0
  private void initMove() {
    final ScriptPaser scriptPaser = new ScriptPaser();
    scriptPaser.paser(context, this, handScriteNames[type_direction]);

    scriptPaser.setScriptTriggerDoCommandLisener(
        new ScriptPaser.ScriptTriggerDoCommandLisener() {

          @Override
          public void onCommandPause() {
            // TODO Auto-generated method stub

          }

          @Override
          public void onCommandMove(float dx, float dy) {
            // TODO Auto-generated method stub
            if (!isMoveable) return;
            if (scriptPaser.isMove()) {
              dx = scriptPaser.getDx();
              Log.e("script dx", dx + "");
              if (scriptPaser.getDx() > 0) {
                if (getX() + w >= moveRage.right) {
                  scriptPaser.setDx(-scriptPaser.getDx());
                }
              } else {
                if (getX() <= moveRage.left) {
                  scriptPaser.setDx(-scriptPaser.getDx());
                }
              }
            }

            dx = scriptPaser.getDx();

            Bullets.this.move(dx, dy);
          }
        });

    movementAction = new MovementActionSetWithThreadPool();
    movementAction.setMovementActionController(new MovementAtionController());
    MovementActionInfo info =
        new MovementActionInfo(
            2000, 1, 0, 4.0f, "", null, false, this, HandAnimaton.Move.getName());
    MovementActionItemBaseReugularFPS action = new MovementActionItemBaseReugularFPS(info);
    movementAction.addMovementAction(action);

    movementAction.isLoop = true;

    movementAction.setTimerOnTickListener(
        new MovementAction.TimerOnTickListener() {

          @Override
          public void onTick(float dx, float dy) {
            // TODO Auto-generated method stub
            if (!isMoveable) return;
            float bottom = Bullets.this.getY() + h;
            float top = Bullets.this.getY();
            Log.e("hand bottom", bottom + "");

            //				if(type_direction == TYPE_TWO_HAND_LEFT_UP || type_direction ==
            // TYPE_TWO_HAND_RIGHT_UP)
            //					dy *= -1;

            if (type == Top) {
              dy = -dy;
            }

            if ((bottom >= limit && type == Down) || (top <= limit && type == Top)) {
              //					dy = -dy;
              //					if(type==Down || (type==Top &&( type_direction == TYPE_TWO_HAND_LEFT_UP ||
              // type_direction == TYPE_TWO_HAND_RIGHT_UP))){
              if (type == Down) {
                type = Top;
                if (reflectCounter == stopRlectCount) {
                  limit = moveRage.height() - moveRage.height() * Math.pow(0.66d, reflectCounter);
                } else {
                  reflectCounter++;
                  limit = moveRage.height() - moveRage.height() * Math.pow(0.66d, reflectCounter);
                }

                drawWithoutClip = true;
                isMoveable = false;

              } else {
                type = Down;
                limit = moveRage.bottom;
              }
            }

            move(dx, dy);
          }
        });

    movementAction.initMovementAction();

    movementAction.start();

    //		setMovementAction(movementAction);

    movementActionShoot = new MovementActionSetWithThreadPool();
    info = new MovementActionInfo(2000, 1, 2, 0, "", null, false);
    MovementActionItemBaseReugularFPS reFlectaction = new MovementActionItemBaseReugularFPS(info);
    movementActionShoot.addMovementAction(reFlectaction);

    movementActionShoot.setTimerOnTickListener(
        new MovementAction.TimerOnTickListener() {

          @Override
          public void onTick(float dx, float dy) {
            // TODO Auto-generated method stub

            move(dx, dy);

            //				scriptPaser.nextScriptLine();

            //				scriptPaser.triggerAndDoCommandInSprite();

          }
        });

    movementActionShoot.initMovementAction();

    movementActionShoot.start();

    setMovementAction(movementActionShoot);
  }