예제 #1
0
  public void makeNormalAnimation() {
    normalAnimation_mine = CCAnimation.animation("animation1", 0.15f);
    for (int i = 2; i <= 5; i++) {
      CCSprite frame =
          CCSprite.sprite(
              String.format("character/char%d_normal%d.png", CurrentUserInformation.userChar, i));
      frame.setScaleX(-1 * Manager.ratio_width);
      frame.setScaleY(Manager.ratio_height);
      frame.setPosition(212 * Manager.ratio_width, 1019 * Manager.ratio_height);
      normalAnimation_mine.addFrame(frame.getTexture());
    }
    normalAnimate_mine = CCAnimate.action(normalAnimation_mine, false);

    normalAnimation_opponent = CCAnimation.animation("animation2", 0.15f);
    opponentCharacter_normal =
        CCSprite.sprite(
            String.format("character/char%d_normal1.png", CurrentUserInformation.opponentchar));
    for (int i = 5; i >= 2; i--) {
      CCSprite frame =
          CCSprite.sprite(
              String.format(
                  "character/char%d_normal%d.png", CurrentUserInformation.opponentchar, i));
      frame.setScaleX(Manager.ratio_width);
      frame.setScaleY(Manager.ratio_height);
      frame.setPosition(508 * Manager.ratio_width, 1019 * Manager.ratio_height);
      normalAnimation_opponent.addFrame(frame.getTexture());
    }
    normalAnimate_opponent = CCAnimate.action(normalAnimation_opponent, true);
  }
예제 #2
0
  public void makeDemagedAnimation() {
    damagedAnimation_mine = CCAnimation.animation("animation5", 0.15f);
    myCharacter_hurted =
        CCSprite.sprite(
            String.format("character/char%d_hurted1.png", CurrentUserInformation.userChar));
    myCharacter_hurted.setPosition(139 * Manager.ratio_width, 1019 * Manager.ratio_height);
    for (int i = 1; i <= 5; i++) {
      CCSprite frame =
          CCSprite.sprite(
              String.format("character/char%d_hurted%d.png", CurrentUserInformation.userChar, i));
      frame.setScaleX(-1 * Manager.ratio_width);
      frame.setScaleY(Manager.ratio_height);
      damagedAnimation_mine.addFrame(frame.getTexture());
    }
    damagedAnimate_mine = CCAnimate.action(damagedAnimation_mine, false);

    damagedAnimation_opponent = CCAnimation.animation("animation6", 0.15f);
    opponentCharacter_hurted =
        CCSprite.sprite(
            String.format("character/char%d_hurted1.png", CurrentUserInformation.opponentchar));
    opponentCharacter_hurted.setPosition(581 * Manager.ratio_width, 1019 * Manager.ratio_height);
    for (int i = 1; i <= 5; i++) {
      CCSprite frame =
          CCSprite.sprite(
              String.format(
                  "character/char%d_hurted%d.png", CurrentUserInformation.opponentchar, i));
      frame.setScaleX(Manager.ratio_width);
      frame.setScaleY(Manager.ratio_height);
      damagedAnimation_opponent.addFrame(frame.getTexture());
    }
    damagedAnimate_opponent = CCAnimate.action(damagedAnimation_opponent, false);
  }
  protected RGLightLayer(ccColor4B color) {
    super(color);
    this.setIsTouchEnabled(true);
    CGSize winSize = CCDirector.sharedDirector().displaySize();

    warning = 0;
    isMoving = false;
    isRed = true;

    _player = CCSprite.sprite("light_runner.png");
    _player.setPosition(CGPoint.ccp(_player.getContentSize().width / 2.0f, 75));

    background = CCSprite.sprite("backyard_bg.png");
    // background.setTag(1);
    background.setAnchorPoint(0, 0);
    addChild(background);

    light = CCSprite.sprite("redlight.png");
    light.setPosition(CGPoint.ccp(winSize.width - 50, 100));
    a = Account.getInstance();
    // this.act=act;

    addChild(light);
    addChild(_player);
    schedule("checkFinished");
    schedule("movePlayer");
    schedule("changeColor", 1.5F);
  }
예제 #4
0
  public EpisodeLayer() {
    this.setIsTouchEnabled(true);

    bg_episode = CCSprite.sprite("episode/bg_episode.png");
    bg_episode.setScaleX(Manager.ratio_width);
    bg_episode.setScaleY(Manager.ratio_height);
    bg_episode.setPosition(360 * Manager.ratio_width, 720 * Manager.ratio_height);
    this.addChild(bg_episode);

    moveToRight = CCMoveBy.action(5f, CGPoint.ccp(-720f * Manager.ratio_width, 0));
    moveToLeft = CCMoveBy.action(5f, CGPoint.ccp(720f * Manager.ratio_width, 0));
    moveOfCloudSequence = CCSequence.actions(moveToRight, moveToLeft);

    cloud = CCSprite.sprite("episode/cloud.png");
    cloud.setScaleX(Manager.ratio_width);
    cloud.setScaleY(Manager.ratio_height);
    cloud.setPosition(720 * Manager.ratio_width, 1033 * Manager.ratio_height);
    cloud.runAction(CCRepeatForever.action(moveOfCloudSequence));
    this.addChild(cloud);

    episodeList = new CCSprite[9];

    for (int i = 0; i < 9; i++) {
      episodeList[i] = CCSprite.sprite(String.format("episode/episode%d.png", i + 1));
      episodeList[i].setScaleX(Manager.ratio_width);
      episodeList[i].setScaleY(Manager.ratio_height);
      if (i >= 6) episodeList[i].setPosition(360 * Manager.ratio_width, 640 * Manager.ratio_height);
      else episodeList[i].setPosition(360 * Manager.ratio_width, 793 * Manager.ratio_height);
      episodeList[i].setVisible(false);
      this.addChild(episodeList[i]);
    }
    episodeList[currentPageNum].setVisible(true);

    bg_episode = CCSprite.sprite("episode/bg_episode.png");

    btn_next_clicked = CCSprite.sprite("episode/btn_next_clicked.png");
    btn_next_unclicked = CCSprite.sprite("episode/btn_next_unclicked.png");

    btn_next = CCMenuItemSprite.item(btn_next_unclicked, btn_next_clicked, this, "updatePage");
    menu_next = CCMenu.menu(btn_next);
    menu_next.setAnchorPoint(0f, 0f);
    menu_next.setPosition(585 * Manager.ratio_width, 1200 * Manager.ratio_height);
    menu_next.setScaleX(Manager.ratio_width);
    menu_next.setScaleY(Manager.ratio_height);
    this.addChild(menu_next);

    btn_skip_clicked = CCSprite.sprite("episode/btn_skip_clicked.png");
    btn_skip_unclicked = CCSprite.sprite("episode/btn_skip_unclicked.png");
    btn_skip = CCMenuItemSprite.item(btn_skip_unclicked, btn_skip_clicked, this, "clickedSkip");
    menu_skip = CCMenu.menu(btn_skip);
    menu_skip.setAnchorPoint(0f, 0f);
    menu_skip.setPosition(136 * Manager.ratio_width, 1200 * Manager.ratio_height);
    menu_skip.setScaleX(Manager.ratio_width);
    menu_skip.setScaleY(Manager.ratio_height);
    this.addChild(menu_skip);
  }
예제 #5
0
  /** 开启游戏前的准备 */
  private void preGame() {

    // 1.回收容器
    chooseContainer.removeSelf();

    // 玩家已有植物容器进行缩放(包含所有已经选择的植物信息)
    choseContainer.setScale(0.65f);

    // 用已选择的植物填充容器,对容器做缩放操作
    for (ShowPlant item : chosePlantList) {
      CCSprite sprite = item.getDefaultImg();
      CGPoint pos =
          CGPoint.ccp(
              sprite.getPosition().x * 0.65f,
              sprite.getPosition().y + (winSize.getHeight() - sprite.getPosition().y) * 0.35f);
      sprite.setPosition(pos);
      sprite.setScale(0.65f);
      this.addChild(sprite);
    }

    // 2.移动地图
    CGPoint pos =
        CGPoint.ccp(
            gameMap.getContentSize().getWidth() / 2, gameMap.getContentSize().getHeight() / 2);
    CCMoveTo moveTo = CCMoveTo.action(1, pos);
    gameMap.runAction(moveTo);

    CCSequence sequence = CCSequence.actions(moveTo, CCCallFunc.action(this, "clearZombies"));
    // 3.回收僵尸
    gameMap.runAction(sequence);
  }
예제 #6
0
  /** 显示容器 */
  public void loadContainer() {
    chooseContainer = CCSprite.sprite("image/fight/chose/fight_choose.png");
    choseContainer = CCSprite.sprite("image/fight/chose/fight_chose.png");

    choseContainer.setAnchorPoint(0, 1);
    choseContainer.setPosition(0, winSize.height);

    chooseContainer.setAnchorPoint(0, 0);
    this.addChild(choseContainer, 0, TAG_CHOSE); // 第二个参数,0,1表示优先级
    this.addChild(chooseContainer, 1);

    // 加载植物信息
    loadPlant();

    // 添加开始图片
    start = CCSprite.sprite("image/fight/chose/fight_start.png");
    start.setPosition(chooseContainer.getContentSize().getWidth() / 2, 40);
    chooseContainer.addChild(start);
  }
예제 #7
0
  /** 播放序列帧,,开始游戏 */
  private void ready() {
    ready = CCSprite.sprite("image/fight/startready_01.png");

    ArrayList<CCSpriteFrame> frames = null;
    ready.setPosition(winSize.getWidth() / 2, winSize.getHeight() / 2);
    this.addChild(ready);
    CCAnimate animate = CommonUtil.getAnimate(frames, 3, "image/fight/startready_%02d.png");
    CCSequence sequence = CCSequence.actions(animate, CCCallFunc.action(this, "go"));
    ready.runAction(sequence);
  }
예제 #8
0
  private void loadPlant() {
    // 展示用的植物信息
    showPlantList = new ArrayList<ShowPlant>();
    // 。。。。
    chosePlantList = new CopyOnWriteArrayList<ShowPlant>();
    for (int i = 1; i <= 9; i++) {

      // 传入ID时就初始化了所以的植物信息
      ShowPlant plant = new ShowPlant(i);
      CCSprite defaultImg = plant.getDefaultImg();
      CCSprite bgImg = plant.getBgImg();
      defaultImg.setPosition((i - 1) % row * 54 + 16, 175 - (i - 1) / row * 59);
      bgImg.setPosition((i - 1) % row * 54 + 16, 175 - (i - 1) / row * 59);
      chooseContainer.addChild(defaultImg);
      chooseContainer.addChild(bgImg);
      showPlantList.add(plant);
    }

    setIsTouchEnabled(true);
  }
예제 #9
0
  public void runAttackAnimation_opponent(int kindOfAttack) {
    SoundEngine.sharedEngine().playEffect(GameActivity.ctxt, R.raw.effect_punch);

    numOfCurrentActions_opponent++;

    CCFiniteTimeAction damagedAction = makeDamagedAction();
    CCSequence opponent_attack_sequence = makeMyDamagedSequence(damagedAction);

    opponentCharacter_normal.stopAction(normalAnimate_opponent);
    opponentCharacter_normal.setVisible(false);
    switch (kindOfAttack) {
      case 1:
        SoundEngine.sharedEngine().playEffect(GameActivity.ctxt, R.raw.effect_bark);

        opponentCharacter_normal.setVisible(false);

        this.addChild(attack_bark_opponent, 1, ACTION_ATTACK_OPPONENT);

        coming_bark.setPosition(495 * Manager.ratio_width, 1030 * Manager.ratio_height);
        this.addChild(coming_bark, 500, ACTION_FLYING_OPPONENT);
        coming_bark.runAction(opponent_attack_sequence);
        break;
      case 2:
        opponentCharacter_normal.setVisible(false);
        this.addChild(attack_bone_opponent, 1, ACTION_ATTACK_OPPONENT);

        coming_bone.setPosition(495 * Manager.ratio_width, 1030 * Manager.ratio_height);
        this.addChild(coming_bone, 500, ACTION_FLYING_OPPONENT);
        coming_bone.runAction(opponent_attack_sequence);
        break;
      case 3:
        opponentCharacter_normal.setVisible(false);
        this.addChild(attack_punch_opponent, 1, ACTION_ATTACK_OPPONENT);

        coming_punch.setPosition(495 * Manager.ratio_width, 1030 * Manager.ratio_height);
        this.addChild(coming_punch, 500, ACTION_FLYING_OPPONENT);
        coming_punch.runAction(opponent_attack_sequence);
        break;
    }
  }
예제 #10
0
  public void runAttackAnimation_mine(int kindOfAttack) {
    SoundEngine.sharedEngine().playEffect(GameActivity.ctxt, R.raw.effect_punch);

    numOfCurrentActions_mine++;

    CCFiniteTimeAction attackAction = makeAttackAction();
    CCSequence my_attack_sequence = makeMyAttackSequence(attackAction);

    myCharacter_normal.stopAction(normalAnimate_mine);
    myCharacter_normal.setVisible(false);
    switch (kindOfAttack) {
      case 1:
        SoundEngine.sharedEngine().playEffect(GameActivity.ctxt, R.raw.effect_bark);

        myCharacter_normal.setVisible(false);
        this.addChild(attack_bark_mine, 1, ACTION_ATTACK_MINE);
        going_bark.setPosition(225 * Manager.ratio_width, 1030 * Manager.ratio_height);
        this.addChild(going_bark, 500, ACTION_FLYING_MINE);
        going_bark.runAction(my_attack_sequence);
        break;
      case 2:
        myCharacter_normal.setVisible(false);
        this.addChild(attack_bone_mine, 1, ACTION_ATTACK_MINE);

        going_bone.setPosition(225 * Manager.ratio_width, 1030 * Manager.ratio_height);
        this.addChild(going_bone, 500, ACTION_FLYING_MINE);
        going_bone.runAction(my_attack_sequence);
        break;
      case 3:
        myCharacter_normal.setVisible(false);
        this.addChild(attack_punch_mine, 1, ACTION_ATTACK_MINE);

        going_punch.setPosition(225 * Manager.ratio_width, 1030 * Manager.ratio_height);
        this.addChild(going_punch, 500, ACTION_FLYING_MINE);
        going_punch.runAction(my_attack_sequence);
        break;
    }
  }
 public void changeColor(float dt) {
   CGSize winSize = CCDirector.sharedDirector().displaySize();
   removeChild(light, true);
   if (isRed) {
     light = CCSprite.sprite("greenlight.png");
     isRed = false;
   } else {
     light = CCSprite.sprite("redlight.png");
     isRed = true;
   }
   warning = 0;
   light.setPosition(CGPoint.ccp(winSize.width - 50, 100));
   addChild(light);
 }
 public void movePlayer(float dt) {
   ActivityAccesser a = ActivityAccesser.getInstance();
   float curr = a.getValues();
   float distance = curr - prev;
   // Log.d("Curr",curr+"");
   // Log.d("Prev",prev+"");
   // Log.d("Distance",distance+"");
   if (prev == 0) {
     prev = curr;
     return;
   }
   prev = curr;
   if (Math.abs(distance) > 2) {
     CGPoint playerPos = _player.getPosition();
     // Log.d("x",playerPos.x+"");
     CGPoint newPoint = CGPoint.ccp(playerPos.x + Math.abs(distance), playerPos.y);
     _player.setPosition(newPoint);
     isMoving = true;
   } else isMoving = false;
 }
예제 #13
0
  private void makeGround() {
    Bitmap bitmap = FronBitmapMaker.getInstance().loadBitmap(R.drawable.land_03_line);
    Bitmap target =
        Bitmap.createBitmap(
            60 * ServerData.mapSize, 30 * ServerData.mapSize + 20, Config.ARGB_8888);
    Canvas can = new Canvas(target);
    CGPoint pt;
    for (int i = 0; i < ServerData.mapSize; i++) {
      for (int j = 0; j < ServerData.mapSize; j++) {
        pt = FronUtil.isoToScreen(CGPoint.ccp(i, j));
        //				Log.i("position", pt.x+","+pt.y);
        can.drawBitmap(bitmap, pt.x + ((ServerData.mapSize - 1) * 30), pt.y, null);
      }
    }
    CCSprite ground = new CCSprite(target, "land_03");
    ground.setPosition(0, -(ServerData.mapSize * 15));
    addChild(ground);

    this.setPosition(400, 300);
    bitmap.recycle();
  }
예제 #14
0
  public BattleLayer() {
    this.setIsTouchEnabled(true);

    btn_skill_bark_activated = CCSprite.sprite("minigame/btn_skill_bark_activated.png");
    btn_skill_bark_normal = CCSprite.sprite("minigame/btn_skill_bark_normal.png");
    btn_skill_bone_activated = CCSprite.sprite("minigame/btn_skill_bone_activated.png");
    btn_skill_bone_normal = CCSprite.sprite("minigame/btn_skill_bone_normal.png");
    btn_skill_punch_activated = CCSprite.sprite("minigame/btn_skill_punch_activated.png");
    btn_skill_punch_normal = CCSprite.sprite("minigame/btn_skill_punch_normal.png");

    gage_bar = CCSprite.sprite("minigame/gage_bar.png");
    gage_bar_black = CCSprite.sprite("minigame/bg_gage_bar.png");

    init_statics();
    init_states();

    gage_bar.setPosition(86 * Manager.ratio_width, 570 * Manager.ratio_height);
    gage_bar.setScaleX(Manager.ratio_width);
    gage_bar.setScaleY(Manager.ratio_height);
    this.addChild(gage_bar);

    gage_bar_black.setPosition(85 * Manager.ratio_width, 765 * Manager.ratio_height);
    gage_bar_black.setAnchorPoint(0.5f, 1f);
    gage_bar_black.setScaleX(Manager.ratio_width);
    gage_bar_black.setScaleY(1 - gage / Manager.full_gage);
    gage_bar_black.setScaleY(Manager.ratio_height);
    this.addChild(gage_bar_black);

    // ��ų ��ư ��ġ ����, ���̾ �߰�
    btn_skill_bark_activated.setPosition(631 * Manager.ratio_width, 733 * Manager.ratio_height);
    btn_skill_bark_activated.setScaleX(Manager.ratio_width); // * Ȯ�� �ʿ�
    btn_skill_bark_activated.setScaleY(Manager.ratio_height);
    this.addChild(btn_skill_bark_activated);
    btn_skill_bark_normal.setPosition(631 * Manager.ratio_width, 733 * Manager.ratio_height);
    btn_skill_bark_normal.setScaleX(Manager.ratio_width); // * Ȯ�� �ʿ�
    btn_skill_bark_normal.setScaleY(Manager.ratio_height);
    this.addChild(btn_skill_bark_normal);

    btn_skill_bone_activated.setPosition(631 * Manager.ratio_width, 589 * Manager.ratio_height);
    btn_skill_bone_activated.setScaleX(Manager.ratio_width);
    btn_skill_bone_activated.setScaleY(Manager.ratio_height);
    this.addChild(btn_skill_bone_activated);
    btn_skill_bone_normal.setPosition(631 * Manager.ratio_width, 589 * Manager.ratio_height);
    btn_skill_bone_normal.setScaleX(Manager.ratio_width);
    btn_skill_bone_normal.setScaleY(Manager.ratio_height);
    this.addChild(btn_skill_bone_normal);

    btn_skill_punch_activated.setPosition(631 * Manager.ratio_width, 439 * Manager.ratio_height);
    btn_skill_punch_activated.setScaleX(Manager.ratio_width);
    btn_skill_punch_activated.setScaleY(Manager.ratio_height);
    this.addChild(btn_skill_punch_activated);
    btn_skill_punch_normal.setPosition(631 * Manager.ratio_width, 439 * Manager.ratio_height);
    btn_skill_punch_normal.setScaleX(Manager.ratio_width);
    btn_skill_punch_normal.setScaleY(Manager.ratio_height);
    this.addChild(btn_skill_punch_normal);

    ////////////////////////////////////////////////////////////////////////////
    bg_battlelayer.setPosition(360 * Manager.ratio_width, 1057 * Manager.ratio_height);
    bg_battlelayer.setScaleX(Manager.ratio_width);
    bg_battlelayer.setScaleY(Manager.ratio_height);
    this.addChild(bg_battlelayer);

    makeNormalAnimation();
    makeDemagedAnimation();

    myCharacter_normal =
        CCSprite.sprite(
            String.format("character/char%d_normal1.png", CurrentUserInformation.userChar));
    myCharacter_normal.setScaleX(-1 * Manager.ratio_width);
    myCharacter_normal.setScaleY(Manager.ratio_height);
    myCharacter_normal.setPosition(212 * Manager.ratio_width, 1019 * Manager.ratio_height);
    myCharacter_normal.runAction(CCRepeatForever.action(normalAnimate_mine));
    this.addChild(myCharacter_normal);

    opponentCharacter_normal =
        CCSprite.sprite(
            String.format("character/char%d_normal1.png", CurrentUserInformation.opponentchar));
    opponentCharacter_normal.setScaleX(Manager.ratio_width);
    opponentCharacter_normal.setScaleY(Manager.ratio_height);
    opponentCharacter_normal.setPosition(508 * Manager.ratio_width, 1019 * Manager.ratio_height);
    opponentCharacter_normal.runAction(CCRepeatForever.action(normalAnimate_opponent));
    this.addChild(opponentCharacter_normal);

    myCharacter_hurted =
        CCSprite.sprite(
            String.format("character/char%d_hurted1.png", CurrentUserInformation.userChar));
    myCharacter_hurted.setScaleX(-1 * Manager.ratio_width);
    myCharacter_hurted.setScaleY(Manager.ratio_height);
    myCharacter_hurted.setPosition(212 * Manager.ratio_width, 1019 * Manager.ratio_height);

    opponentCharacter_hurted =
        CCSprite.sprite(
            String.format("character/char%d_hurted1.png", CurrentUserInformation.opponentchar));
    opponentCharacter_hurted.setScaleX(Manager.ratio_width);
    opponentCharacter_hurted.setScaleY(Manager.ratio_height);
    opponentCharacter_hurted.setPosition(508 * Manager.ratio_width, 1019 * Manager.ratio_height);

    bg_hp_bar.setPosition(360 * Manager.ratio_width, 1240 * Manager.ratio_height);
    bg_hp_bar.setScaleX(-1 * Manager.ratio_width);
    bg_hp_bar.setScaleY(Manager.ratio_height);
    this.addChild(bg_hp_bar);

    hp_bar_mine.setPosition(321 * Manager.ratio_width, 1240 * Manager.ratio_height);
    hp_bar_mine.setScaleX(Manager.ratio_width);
    hp_bar_mine.setScaleY(Manager.ratio_height);
    hp_bar_mine.setAnchorPoint(1f, 0.5f);
    this.addChild(hp_bar_mine);

    hp_bar_opponent.setPosition(400 * Manager.ratio_width, 1240 * Manager.ratio_height);
    hp_bar_opponent.setScaleX(Manager.ratio_width);
    hp_bar_opponent.setScaleY(Manager.ratio_height);
    hp_bar_opponent.setAnchorPoint(0f, 0.5f);
    this.addChild(hp_bar_opponent);

    title.setPosition(360 * Manager.ratio_width, 1235 * Manager.ratio_height);
    title.setScaleX(Manager.ratio_width);
    title.setScaleY(Manager.ratio_height);
    this.addChild(title);

    attack_bark_opponent =
        CCSprite.sprite(
            String.format("character/attack_bark%d.png", CurrentUserInformation.opponentchar));
    attack_bark_opponent.setScaleX(Manager.ratio_width);
    attack_bark_opponent.setScaleY(Manager.ratio_height);
    attack_bark_opponent.setPosition(508 * Manager.ratio_width, 1019 * Manager.ratio_height);
    attack_bark_mine =
        CCSprite.sprite(
            String.format("character/attack_bark%d.png", CurrentUserInformation.userChar));
    attack_bark_mine.setPosition(212 * Manager.ratio_width, 1019 * Manager.ratio_height);
    attack_bark_mine.setScaleX(-1 * Manager.ratio_width);
    attack_bark_mine.setScaleY(Manager.ratio_height);

    attack_bone_opponent =
        CCSprite.sprite(
            String.format("character/attack_bone%d.png", CurrentUserInformation.opponentchar));
    attack_bone_opponent.setScaleX(Manager.ratio_width);
    attack_bone_opponent.setScaleY(Manager.ratio_height);
    attack_bone_opponent.setPosition(508 * Manager.ratio_width, 1019 * Manager.ratio_height);
    attack_bone_mine =
        CCSprite.sprite(
            String.format("character/attack_bone%d.png", CurrentUserInformation.userChar));
    attack_bone_mine.setScaleX(-1 * Manager.ratio_width);
    attack_bone_mine.setScaleY(Manager.ratio_height);
    attack_bone_mine.setPosition(212 * Manager.ratio_width, 1019 * Manager.ratio_height);

    attack_punch_opponent =
        CCSprite.sprite(
            String.format("character/attack_punch%d.png", CurrentUserInformation.opponentchar));
    attack_punch_opponent.setScaleX(Manager.ratio_width);
    attack_punch_opponent.setScaleY(Manager.ratio_height);
    attack_punch_opponent.setPosition(508 * Manager.ratio_width, 1019 * Manager.ratio_height);
    attack_punch_mine =
        CCSprite.sprite(
            String.format("character/attack_punch%d.png", CurrentUserInformation.userChar));
    attack_punch_mine.setScaleX(-1 * Manager.ratio_width);
    attack_punch_mine.setScaleY(Manager.ratio_height);
    attack_punch_mine.setPosition(212 * Manager.ratio_width, 1019 * Manager.ratio_height);

    coming_bark = CCSprite.sprite("battle/coming_bark.png");
    coming_bark.setScaleX(Manager.ratio_width);
    coming_bark.setScaleY(Manager.ratio_height);
    going_bark = CCSprite.sprite("battle/coming_bark.png");
    going_bark.setScaleX(-1 * Manager.ratio_width);
    going_bark.setScaleY(Manager.ratio_height);

    coming_bone = CCSprite.sprite("battle/coming_bone.png");
    coming_bone.setScaleX(Manager.ratio_width);
    coming_bone.setScaleY(Manager.ratio_height);

    going_bone = CCSprite.sprite("battle/coming_bone.png");
    going_bone.setScaleX(-1 * Manager.ratio_width);
    going_bone.setScaleY(Manager.ratio_height);

    coming_punch = CCSprite.sprite("battle/coming_punch.png");
    coming_punch.setScaleX(Manager.ratio_width);
    coming_punch.setScaleY(Manager.ratio_height);

    going_punch = CCSprite.sprite("battle/coming_punch.png");
    going_punch.setScaleX(-1 * Manager.ratio_width);
    going_punch.setScaleY(Manager.ratio_height);

    danger = CCSprite.sprite("minigame/danger.png");
    danger.setScaleX(Manager.ratio_width);
    danger.setScaleY(Manager.ratio_height);
    danger.setPosition(360 * Manager.ratio_width, 833 * Manager.ratio_height);
    danger.setVisible(false);
    this.addChild(danger);

    bg_danger = CCSprite.sprite("minigame/bg_danger.png");
    bg_danger.setScaleX(Manager.ratio_width);
    bg_danger.setScaleY(Manager.ratio_height);
    bg_danger.setPosition(360 * Manager.ratio_width, 640 * Manager.ratio_height);
    bg_danger.setVisible(false);
    this.addChild(bg_danger);

    CCFiniteTimeAction action_waitFight =
        CCMoveTo.action(2f, CGPoint.ccp(-360 * Manager.ratio_width, 826 * Manager.ratio_height));
    CCFiniteTimeAction action_incomingFight =
        CCMoveTo.action(0.3f, CGPoint.ccp(360 * Manager.ratio_width, 826 * Manager.ratio_height));
    CCFiniteTimeAction action_delayFight =
        CCMoveTo.action(0.5f, CGPoint.ccp(360 * Manager.ratio_width, 826 * Manager.ratio_height));
    CCFiniteTimeAction action_outgoingFight =
        CCMoveTo.action(0.3f, CGPoint.ccp(1080 * Manager.ratio_width, 826 * Manager.ratio_height));
    CCCallFuncN tellFight = CCCallFuncN.action(this, "tellFight");
    CCCallFuncN removeFight = CCCallFuncN.action(this, "removeFight");

    CCSequence sequence_fight =
        CCSequence.actions(
            action_waitFight,
            tellFight,
            action_incomingFight,
            action_delayFight,
            action_outgoingFight,
            removeFight);
    fight = CCSprite.sprite("minigame/fight.png");
    fight.setPosition(-360, 826);
    fight.setScaleX(Manager.ratio_width);
    fight.setScaleY(Manager.ratio_height);
    fight.runAction(sequence_fight);
    this.addChild(fight);

    NetworkManager.getInstance().setGetDamagedCallback(this);
  }
예제 #15
0
  public MenuLayer(boolean playMusic) {
    if (playMusic) {
      if (G.bgSound.isPlaying()) G.bgSound.pause();
      G.bgSound = G.soundMenu;
      if (G.music) G.bgSound.start();
    }

    setScale(G.scale);
    setAnchorPoint(0, 0);

    // background
    CCSprite bg = new CCSprite("background/game_bg0.png");
    bg.setPosition(G.displayCenter());
    addChild(bg);

    CCSprite bird = new CCSprite("menu/bird.png");
    bird.setAnchorPoint(0, 0);
    bird.setPosition(0, 0);
    addChild(bird);

    CCSprite leaves = new CCSprite("menu/leaves.png");
    leaves.setAnchorPoint(0, 1);
    leaves.setPosition(0, G.height);
    addChild(leaves);

    CCSprite title = new CCSprite("menu/title.png");
    title.setPosition(G.width * 0.47f, G.height * 0.83f);
    addChild(title);

    // remove Ads
    /*CCMenuItemImage removeAds = CCMenuItemImage.item("menu/no_ads.png", "menu/no_ads.png", this, "removeAds_Menu");
    removeAds.setAnchorPoint(1, 0);
    removeAds.setPosition(G.width, G.height*0.4f);*/

    // buttons
    CCMenuItemImage play = CCMenuItemImage.item("menu/play1.png", "menu/play2.png", this, "onPlay");
    play.setAnchorPoint(1, 0);
    play.setPosition(G.width, 0);

    CCMenuItemToggle sound =
        CCMenuItemToggle.item(
            this,
            "onSound",
            CCMenuItemImage.item("menu/sound_off.png", "menu/sound_off.png"),
            CCMenuItemImage.item("menu/sound_on.png", "menu/sound_on.png"));
    sound.setSelectedIndex(G.sound ? 1 : 0);
    sound.setPosition(G.width * 0.4f, 70);

    CCMenuItemToggle music =
        CCMenuItemToggle.item(
            this,
            "onMusic",
            CCMenuItemImage.item("menu/music_off.png", "menu/music_off.png"),
            CCMenuItemImage.item("menu/music_on.png", "menu/music_on.png"));
    music.setSelectedIndex(G.music ? 1 : 0);
    music.setPosition(G.width * 0.5f, 70);

    CCMenuItemImage game_center =
        CCMenuItemImage.item(
            "menu/leaderboard.png", "menu/leaderboard_clicked.png", this, "onLeaderBoard");
    game_center.setAnchorPoint(0.5f, 0);
    game_center.setPosition(G.width * 0.5f, 140);

    // for more
    CCMenuItemImage moreItem =
        CCMenuItemImage.item("menu/more.png", "menu/more1.png", this, "openMoreGames");
    moreItem.setAnchorPoint(0.5f, 0);
    moreItem.setPosition(G.width * 0.4f, 140);

    CCMenuItemImage moreItem2 =
        CCMenuItemImage.item("menu/more2.png", "menu/more2.png", this, "superchaves");
    moreItem2.setAnchorPoint(0.5f, 0);
    moreItem2.setPosition(G.width * 0.6f, 140);

    CCMenu menu = CCMenu.menu(/*removeAds ,*/ play, sound, music, game_center, moreItem, moreItem2);
    menu.setPosition(0, 0);
    addChild(menu);

    setIsKeyEnabled(true);
  }
  protected void initGame(boolean firstTime, Object sender) {
    super.initGame(firstTime, sender);
    super.clearFloatingSprites();

    switch (mLevel) {
      case 1:
        number_of_item_type = 1;
        number_of_item_max = 5;
        break;
      case 2:
        number_of_item_type = 2;
        number_of_item_max = 5;
        break;
      case 3:
        number_of_item_type = 3;
        number_of_item_max = 5;
        break;
      case 4:
        number_of_item_type = 3;
        number_of_item_max = 5;
        break;
      case 5:
        number_of_item_type = 4;
        number_of_item_max = 5;
        break;
      case 6:
        number_of_item_type = 4;
        number_of_item_max = 6;
        break;
      case 7:
        number_of_item_type = 4;
        number_of_item_max = 7;
        break;
      case 8:
        number_of_item_type = 4;
        number_of_item_max = 9;
        break;
      default:
        number_of_item_type = 5;
        number_of_item_max = 9;
    }
    // make sure the number_of_item_max is less than 10
    if (number_of_item_max > 9) number_of_item_max = 9;

    int selectedTypes[] = new int[items.size()];
    for (int i = 0; i < items.size(); ++i) selectedTypes[i] = i;
    super.randomIt(selectedTypes, items.size());

    float answerAreaWidth = szWin.width / 5;
    float yAnswer = yKeyboardTop;

    for (int i = 0; i < number_of_item_type; ++i) {
      number_of_item_each_type[i] = randomBetween(1, number_of_item_max);
      answer_of_item_each_type[i] = -1; // set as not answered yet
      // make sure each type is different from others
      item_type[i] = selectedTypes[i];
      // display these items
      for (int j = 0; j < number_of_item_each_type[i]; ++j) {
        CCSprite sprite = spriteFromExpansionFile(items.get(item_type[i]));
        sprite.setScale(preferredContentScale(true));
        float xRandom = super.nextInt((int) (szWin.width - answerAreaWidth));
        if (xRandom - sprite.getContentSize().width * sprite.getScale() / 2 < 0)
          xRandom = sprite.getContentSize().width * sprite.getScale() / 2;
        else if (xRandom + sprite.getContentSize().width * sprite.getScale() / 2
            > szWin.width - answerAreaWidth)
          xRandom =
              szWin.width - answerAreaWidth - sprite.getContentSize().width * sprite.getScale() / 2;
        float yRandom = super.nextInt((int) szWin.height);
        if (yRandom - sprite.getContentSize().height * sprite.getScale() / 2 < yKeyboardTop)
          yRandom = yKeyboardTop + sprite.getContentSize().height * sprite.getScale() / 2;
        else if (yRandom + sprite.getContentSize().height * sprite.getScale() / 2
            > szWin.height - topOverhead())
          yRandom =
              szWin.height - topOverhead() - sprite.getContentSize().height * sprite.getScale() / 2;
        sprite.setPosition(xRandom, yRandom);
        sprite.setTag(kTagItem);

        super.addChild(sprite, 1);
        floatingSprites.add(sprite);
      }
      // the answer for this item
      CCSprite sprite =
          spriteFromExpansionFile(
              "image/activities/math/numeration/enumerate/enumerate_answer.png");
      sprite.setPosition(
          szWin.width - answerAreaWidth / 2, yAnswer + sprite.getContentSize().height / 2);
      sprite.setTag(kTagAnswerBg + i);
      super.addChild(sprite, 1);
      floatingSprites.add(sprite);

      // the icon
      CCSprite icon = spriteFromExpansionFile(items.get(item_type[i]));
      icon.setScale(sprite.getContentSize().height / icon.getContentSize().height * 0.5f);
      icon.setPosition(
          sprite.getPosition().x
              - sprite.getContentSize().width / 2
              + 4
              + icon.getContentSize().width * icon.getScale() / 2,
          sprite.getPosition().y);
      super.addChild(icon, 1);
      floatingSprites.add(icon);

      // the lable on it
      CCLabel label = CCLabel.makeLabel("?", super.sysFontName(), super.mediumFontSize());
      label.setColor(ccColor3B.ccBLACK);
      label.setPosition(
          sprite.getPosition().x + label.getContentSize().width, sprite.getPosition().y);
      super.addChild(label, 3);
      floatingSprites.add(label);

      sprite.setUserData(label);

      // move top a little for next item answer
      yAnswer += sprite.getContentSize().height + 6;
    }
    answeringIndex = 0; // start to answer the first type of items
    this.refreshAnswers();
  }