示例#1
0
 // do nothing yet...
 public static final void CC_DIRECTOR_END() {
   CCDirector director = CCDirector.sharedDirector();
   GLSurfaceView view = director.getOpenGLView();
   ViewGroup vg = (ViewGroup) view.getParent();
   vg.removeView(view);
   director.end();
 }
 private void verificaFinalDoJogo() {
   if (quantBotoesClicados >= 23) {
     insereJogador();
     ToastManager.show(
         CCDirector.sharedDirector().getActivity(), "Congratulations! :)", ToastManager.SUCESS);
     executarTempo(3000);
     delegate.iniciarFinaldoJogo();
     SoundEngine.sharedEngine().pauseSound();
     SoundEngine.sharedEngine()
         .playEffect(CCDirector.sharedDirector().getActivity(), R.raw.finalend);
   }
 }
示例#3
0
  public void clickedSkip(Object sender) {
    SoundEngine.sharedEngine()
        .playEffect(CCDirector.sharedDirector().getActivity(), R.raw.effect_button);

    if (currentPage == 1) {
      currentPageNum = 6;
      currentPage = 2;
      updatePage(sender);
    } else {
      CCScene scene = ReadyToFightLayer.makeScene();
      CCDirector.sharedDirector().replaceScene(scene);
    }
  }
示例#4
0
  public void updatePage(Object sender) {
    SoundEngine.sharedEngine()
        .playEffect(CCDirector.sharedDirector().getActivity(), R.raw.effect_button);

    if (currentPageNum == 8) {
      CCScene scene = ReadyToFightLayer.makeScene();
      CCDirector.sharedDirector().replaceScene(scene);
    }
    currentPageNum++;
    for (int i = 0; i < 9; i++) {
      if (i == currentPageNum) episodeList[i].setVisible(true);
      else episodeList[i].setVisible(false);
    }
  }
  public void onPlay(Object sender) {
    if (G.sound) G.soundClick.start();

    CCScene s = CCScene.node();
    s.addChild(new SelectLayer(false));
    CCDirector.sharedDirector().replaceScene(CCFadeTransition.transition(0.7f, s));
  }
  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);
  }
  @Override
  public void onDestroy() {
    super.onDestroy();

    CCDirector.sharedDirector().end();
    // CCTextureCache.sharedTextureCache().removeAllTextures();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    mGLSurfaceView = new CCGLSurfaceView(this);
    CCDirector director = CCDirector.sharedDirector();
    director.attachInView(mGLSurfaceView);
    director.setDeviceOrientation(CCDirector.kCCDeviceOrientationLandscapeLeft);
    setContentView(mGLSurfaceView);

    // show FPS
    CCDirector.sharedDirector().setDisplayFPS(true);

    // frames per second
    CCDirector.sharedDirector().setAnimationInterval(1.0f / 60.0f);

    CCScene scene = CCScene.node();
    scene.addChild(new Box2DTestLayer());

    // Make the Scene active
    CCDirector.sharedDirector().runWithScene(scene);
  }
    @Override
    public boolean ccTouchesBegan(MotionEvent event) {
      CGPoint location =
          CCDirector.sharedDirector().convertToGL(CGPoint.make(event.getX(), event.getY()));

      addNewSpriteWithCoords(location);

      return CCTouchDispatcher.kEventHandled;
    }
  public void onSound(Object sender) {
    if (G.sound) G.soundClick.start();

    G.sound = !G.sound;
    SharedPreferences sp =
        CCDirector.sharedDirector().getActivity().getSharedPreferences("GameInfo", 0);
    SharedPreferences.Editor et = sp.edit();
    et.putBoolean("sound", G.sound);
    et.commit();
  }
 private void insereJogador() {
   if (nome.equals("")) {
     nome = "Player";
   }
   JogadorDao dao = new JogadorDao(CCDirector.sharedDirector().getActivity());
   Jogador jogador = new Jogador();
   jogador.setNome(nome);
   jogador.setPontos(delegate.score.getScore());
   dao.salvar(jogador);
 }
  public void buttonClicked(CCSprite sender) {

    // inicio da verificação
    for (int i = 0; i < imagens.length; i++) {
      // indentifica qual foi o botao clicado do meu vetor
      if (sender.equals(imagens[i])) {

        // primeira jogada
        if (ultimoBotaoClicado == -1) {

          this.primeiraPosicao = imagens[i].getPosition();
          mostra(i, primeiraPosicao);
          ultimoBotaoClicado = i;
        }
        // segunda jogada
        else if (retornoCategoria[i] == retornoCategoria[ultimoBotaoClicado]) {
          quantBotoesClicados += 2;
          this.segundaPosicao = imagens[i].getPosition();
          mostra(i, segundaPosicao);
          ToastManager.show(
              CCDirector.sharedDirector().getActivity(),
              retornoCategoria[i].toString().substring(0, retornoCategoria[i].length() - 4),
              ToastManager.SUCESS);
          ultimoBotaoClicado = -1;
          delegate.score.acrecenta();
          verificaFinalDoJogo();
          // desabilita o touch da imagem
        } else {

          this.segundaPosicao = imagens[i].getPosition();
          mostra(i, segundaPosicao);
          x = i;
          this.setIsTouchEnabled(false);
          // executarTempo(2000);
          Runnable run =
              new Runnable() {
                @Override
                public void run() {
                  esconde(ultimoBotaoClicado, primeiraPosicao);
                  esconde(x, imagens[x].getPosition());
                  ToastManager.show(
                      CCDirector.sharedDirector().getActivity(), " Ops :(", ToastManager.ERROR);
                  ultimoBotaoClicado = -1;
                  primeiraPosicao = null;
                  segundaPosicao = null;
                  delegate.score.tira();
                  setIsTouchEnabled(true);
                }
              };
          // tempo de 1 segundos
          tempo.schedule(run, 1, TimeUnit.SECONDS);
        }
      }
    }
  }
示例#13
0
 @Override
 public boolean ccTouchesBegan(MotionEvent event) {
   CGPoint touchPoint =
       CCDirector.sharedDirector().convertToGL(CGPoint.ccp(event.getX(), event.getY()));
   if (btn_skill_bark_normal.getBoundingBox().contains(touchPoint.x, touchPoint.y)
       && gage >= Manager.required_gage_for_skill_bark) {
     SoundEngine.sharedEngine()
         .playEffect(CCDirector.sharedDirector().getActivity(), R.raw.effect_button);
     gage -= Manager.required_gage_for_skill_bark;
     hp_opponent -= Manager.damaged_hp_per_attack_bark;
     updateSkillBtns();
     updateGageBar();
     runAttackAnimation_mine(1);
     NetworkManager.getInstance().sendAttack(SkillType.BARK);
   } else if (btn_skill_bone_normal.getBoundingBox().contains(touchPoint.x, touchPoint.y)
       && gage >= Manager.required_gage_for_skill_bone) {
     SoundEngine.sharedEngine()
         .playEffect(CCDirector.sharedDirector().getActivity(), R.raw.effect_button);
     gage -= Manager.required_gage_for_skill_bone;
     hp_opponent -= Manager.damaged_hp_per_attack_bone;
     updateSkillBtns();
     updateGageBar();
     runAttackAnimation_mine(2);
     NetworkManager.getInstance().sendAttack(SkillType.BONE);
     /// * �������� ��� ���� ���
   } else if (btn_skill_punch_normal.getBoundingBox().contains(touchPoint.x, touchPoint.y)
       && gage >= Manager.required_gage_for_skill_punch) {
     SoundEngine.sharedEngine()
         .playEffect(CCDirector.sharedDirector().getActivity(), R.raw.effect_button);
     gage -= Manager.required_gage_for_skill_punch;
     hp_opponent -= Manager.damaged_hp_per_attack_punch;
     updateSkillBtns();
     updateGageBar();
     runAttackAnimation_mine(3);
     NetworkManager.getInstance().sendAttack(SkillType.PUNCH);
     /// * �������� ��� ���� ���
   }
   return super.ccTouchesBegan(event);
 }
示例#14
0
 public boolean ccTouchesEnded(MotionEvent event) {
   if (firstPt != null) {
     if (!isMoving) {
       CGPoint pt =
           CCDirector.sharedDirector().convertToGL(CGPoint.make(event.getX(), event.getY()));
       if ((Math.abs(pt.x - firstPt.x) < 5) && (Math.abs(pt.y - firstPt.y) < 5)) {
         CGPoint nodeConvert = this.convertToNodeSpace(pt);
         touched(nodeConvert);
       }
     }
     firstPt = null;
   }
   return true;
 }
 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 onMusic(Object sender) {
    if (G.sound) G.soundClick.start();

    G.music = !G.music;
    SharedPreferences sp =
        CCDirector.sharedDirector().getActivity().getSharedPreferences("GameInfo", 0);
    SharedPreferences.Editor et = sp.edit();
    et.putBoolean("music", G.music);
    et.commit();

    if (G.music) {
      G.bgSound.start();
    } else {
      G.bgSound.pause();
    }
  }
  @Override
  public boolean ccTouchesBegan(MotionEvent event) {
    CGPoint touchLocation = CGPoint.make(event.getX(), event.getY());

    touchLocation = CCDirector.sharedDirector().convertToGL(touchLocation);
    touchLocation = this.convertToNodeSpace(touchLocation);

    // Verifica toque no bot��o

    for (int i = 0; i < imagens.length; i++) {
      if (CGRect.containsPoint(this.imagens[i].getBoundingBox(), touchLocation)) {
        this.buttonClicked(imagens[i]);
      }
    }
    return true;
  }
示例#18
0
  // not supported yet...
  public static final void CC_DIRECTOR_INIT(Activity app) {
    CCDirector director = CCDirector.sharedDirector();
    director.setDeviceOrientation(CCDirector.kCCDeviceOrientationPortrait);
    director.setDisplayFPS(false);
    director.setAnimationInterval(1.0 / 60);

    CCGLSurfaceView sv = new CCGLSurfaceView(app);

    director.attachInView(sv);
    app.setContentView(sv);
  }
示例#19
0
 public boolean ccTouchesBegan(MotionEvent event) {
   Log.i("maplayer", "touch");
   isMoving = false;
   if (event.getPointerCount() > 1) {
     multi1 = CGPoint.make(event.getX(0), event.getY(0));
     multi2 = CGPoint.make(event.getX(1), event.getY(1));
   } else {
     beforePt = CCDirector.sharedDirector().convertToGL(CGPoint.make(event.getX(), event.getY()));
     firstPt = CGPoint.make(beforePt.x, beforePt.y);
     // item check. set selected item.
     if (currentItem != null) {
       CGPoint nodeConvert = this.convertToNodeSpace(beforePt);
       if (currentItem.checkDown(nodeConvert)) {
         isMoving = true;
       }
     }
   }
   return CCTouchDispatcher.kEventHandled;
 }
示例#20
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    app = this;
    myHelper = new MySQLiteHelper(this, "my.db", null, 1);
    // 将文件中的内容保存到数据库中
    insertAndUpdateData(myHelper);
    int testnum = GetNum();
    testnum--;
    String s = MainActivity.queryData(myHelper, testnum * 20 + 1, testnum * 20 + 20);
    int cnt = 0, num = 0;
    String temp = "";
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == '\n') {
        num++;
        temp += s.charAt(i);
        if (num % 2 == 0) {
          strArray[cnt++] = temp;
          temp = "";
          num = 0;
        }
      } else {
        temp += s.charAt(i);
      }
    }
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    mGLSurfaceView = new CCGLSurfaceView(this);
    setContentView(mGLSurfaceView);

    CCDirector my_director = CCDirector.sharedDirector();
    my_director.attachInView(mGLSurfaceView);

    CCDirector.sharedDirector().setDisplayFPS(true);
    CCDirector.sharedDirector().setAnimationInterval(1.0f / 30);

    CCScene scene = CCScene.node();

    MenuLayer menuLayer = new MenuLayer();
    scene.addChild(menuLayer);

    CCDirector.sharedDirector().runWithScene(scene);
  }
 public void checkFinished(float dt) {
   CGPoint playerPos = _player.getPosition();
   CGSize winSize = CCDirector.sharedDirector().displaySize();
   background.setContentSize(winSize.width, winSize.height);
   if (isMoving && isRed && warning == 1) {
     Log.d("checkFinished", "Player Loses");
     a.decScore();
     ActivityAccesser.getInstance().setCompWin(true);
     ActivityAccesser.getInstance().setPlayedGame(true);
     rlActivity.finish();
   } else if (isMoving && isRed && warning == 1) {
     warning++;
   } else if (playerPos.x >= (winSize.width - 50)) {
     Log.d("checkFinished", "Player Wins");
     a.incScore();
     ActivityAccesser.getInstance().setCompWin(false);
     ActivityAccesser.getInstance().setPlayedGame(true);
     rlActivity.finish();
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    CCGLSurfaceView surfaceView = new CCGLSurfaceView(this);
    setContentView(surfaceView);

    director = CCDirector.sharedDirector();
    director.attachInView(surfaceView); // ¿ªÆôÏß³Ì

    director.setDeviceOrientation(CCDirector.kCCDeviceOrientationLandscapeLeft);
    director.setDisplayFPS(true);
    director.setScreenSize(480, 320);

    CCScene ccScene = CCScene.node();
    ccScene.addChild(new WelcomLayer());
    director.runWithScene(ccScene);
  }
 public boolean ccTouchesBegan(MotionEvent event) {
   CGPoint p1 = CCDirector.sharedDirector().convertToGL(CGPoint.ccp(event.getX(), event.getY()));
   pickedSprite = null;
   CCNode clicked = null;
   for (CCNode node : floatingSprites) {
     if (super.isNodeHit(node, p1)) {
       if (node.getTag() == kTagItem) {
         clicked = node;
         break;
       } else if (node.getTag() >= kTagAnswerBg) {
         answeringIndex = node.getTag() - kTagAnswerBg;
         this.refreshAnswers();
         super.playSound("audio/sounds/prompt.wav");
       }
     }
   }
   if (clicked != null) {
     clicked.setPosition(p1);
     pickedSprite = clicked;
     super.playSound("audio/sounds/line_end.wav");
   }
   return true;
 }
示例#24
0
  public boolean ccTouchesMoved(MotionEvent event) {
    if (event.getPointerCount() > 1) {
      currentItem = null;
      CGPoint current1 = CGPoint.make(event.getX(0), event.getY(0));
      CGPoint current2 = CGPoint.make(event.getX(1), event.getY(1));
      float before = getDistance(multi1, multi2);
      float current = getDistance(current1, current2);
      changeScale(current - before);
      multi1 = current1;
      multi2 = current2;
    } else {

      if (firstPt != null) {
        CGPoint convertedLocation =
            CCDirector.sharedDirector().convertToGL(CGPoint.make(event.getX(), event.getY()));
        CGPoint current = getPosition();
        if (currentItem != null && GameStatus.isShowRoundMenu && isMoving) {
          currentItem.moveBy(convertedLocation.x - beforePt.x, convertedLocation.y - beforePt.y);
          SceneManager.getInstance()
              .interfaceLayer
              .moveByRoundMenu(convertedLocation.x - beforePt.x, convertedLocation.y - beforePt.y);
        } else {
          setPosition(
              current.x + (convertedLocation.x - beforePt.x),
              current.y + (convertedLocation.y - beforePt.y));
          if (GameStatus.isShowRoundMenu) {
            SceneManager.getInstance()
                .interfaceLayer
                .moveByRoundMenu(
                    convertedLocation.x - beforePt.x, convertedLocation.y - beforePt.y);
          }
        }
        beforePt = convertedLocation;
      }
    }
    return true;
  }
示例#25
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   ccglSurfaceView = new CCGLSurfaceView(this);
   setContentView(ccglSurfaceView);
   // 导演(单列模式)
   ccDirector = CCDirector.sharedDirector();
   // 开启线程
   ccDirector.attachInView(ccglSurfaceView);
   // 设置方向
   ccDirector.setDeviceOrientation(CCDirector.kCCDeviceOrientationLandscapeLeft);
   // 设置屏幕分辨率(自动适配)
   ccDirector.setScreenSize(480, 320);
   // 显示当前游戏的帧率 30
   ccDirector.setDisplayFPS(true);
   // 创建场景
   ccScene = CCScene.node();
   // 添加图层
   ccScene.addChild(new MapLayer());
   // 导演运行场景
   ccDirector.runWithScene(ccScene);
 }
示例#26
0
  protected CCParticleSpiral(int p) {
    super(p);

    // duration
    duration = kCCParticleDurationInfinity;

    // Gravity Mode
    emitterMode = kCCParticleModeGravity;

    // Gravity Mode: gravity
    this.setGravity(CGPoint.zero());

    // Gravity Mode: speed of particles
    setSpeed(150);
    setSpeedVar(0);

    // Gravity Mode: radial
    setRadialAccel(-380);
    setRadialAccelVar(0);

    // Gravity Mode: tagential
    setTangentialAccel(45);
    setTangentialAccelVar(0);

    // angle
    angle = 90;
    angleVar = 0;

    // emitter position
    CGSize winSize = CCDirector.sharedDirector().winSize();
    this.setPosition(CGPoint.ccp(winSize.width / 2, winSize.height / 2));
    posVar = CGPoint.zero();

    // life of particles
    life = 12;
    lifeVar = 0;

    // size, in pixels
    startSize = 20.0f;
    startSizeVar = 0.0f;
    endSize = kCCParticleStartSizeEqualToEndSize;

    // emits per second
    emissionRate = totalParticles / life;

    // color of particles
    startColor.r = 0.5f;
    startColor.g = 0.5f;
    startColor.b = 0.5f;
    startColor.a = 1.0f;
    startColorVar.r = 0.5f;
    startColorVar.g = 0.5f;
    startColorVar.b = 0.5f;
    startColorVar.a = 0.0f;
    endColor.r = 0.5f;
    endColor.g = 0.5f;
    endColor.b = 0.5f;
    endColor.a = 1.0f;
    endColorVar.r = 0.5f;
    endColorVar.g = 0.5f;
    endColorVar.b = 0.5f;
    endColorVar.a = 0.0f;

    setTexture(CCTextureCache.sharedTextureCache().addImage("fire.png"));

    // additive
    setBlendAdditive(false);
  }
 @Override
 protected void onPause() {
   super.onPause();
   director.pause();
 }
 @Override
 protected void onDestroy() {
   super.onDestroy();
   director.end();
 }
 @Override
 protected void onResume() {
   super.onResume();
   director.resume();
 }
示例#30
0
 public void onDestroy() {
   SQLiteDatabase db = myHelper.getWritableDatabase();
   db.delete("test_info", "1", null);
   super.onDestroy();
   CCDirector.sharedDirector().end();
 }