Ejemplo n.º 1
0
  void Player::moveTo(const CCPoint& pos, const std::vector<CCPoint>& path) {
    if(!path.empty()) {
      std::vector<MoveInfo> moveInfos;
      for(auto& p : path) {
        moveInfos.push_back(MoveInfo(p));
      }

      auto action = createAnimation(m_animTextureName,
          moveInfos,
          CCSize(48, 48),
          4,
          0.1f,
          1);
      //CCHide * hide= CCHide::create();
      m_sprite->runAction(action);
      action = createMoveAction(
          moveInfos,
          CCSize(48 * m_scale, 48 * m_scale),
          0.4f);
      CCCallFunc* fun = CCCallFunc::create(getScene(), callfunc_selector(HelloWorld::inChooseActionState));

      runAction(CCSequence::create(action, fun, 0));
    }

  }
Ejemplo n.º 2
0
static Action::Ptr createGrabAndMoveAction(GraspingActionContext &ctx, stringstream &ss) {
    // format: grab_and_move <grabstr> <movestr>
    string op;
    ss >> op; BOOST_ASSERT(op == "grab");
    Action::Ptr grabaction = createGrabAction(ctx, ss);
    ss >> op; BOOST_ASSERT(op == "move");
    Action::Ptr moveaction = createMoveAction(ctx, ss);
    ActionChain::Ptr chain(new ActionChain);
    *chain << grabaction << moveaction;
    return chain;
}
Ejemplo n.º 3
0
Action::Ptr GraspingActionSpec::createAction(GraspingActionContext &ctx) const {
    stringstream ss;
    ss << specstr;
    string op; ss >> op; // consume type
    switch (type) {
    case GRAB: return createGrabAction(ctx, ss); break;
    case RELEASE: return createReleaseAction(ctx, ss); break;
    case MOVE: return createMoveAction(ctx, ss); break;
    case GRAB_AND_MOVE: return createGrabAndMoveAction(ctx, ss); break;
    }
    if (op != "none")
        cout << "warning: unrecognized action op " << op << endl;
    return createNoneAction();
};