Exemple #1
0
/**
 * \brief Suspends or resumes the animation.
 *
 * Nothing is done if the parameter specified does not change.
 *
 * \param suspended true to suspend the animation, false to resume it
 */
void Sprite::set_suspended(bool suspended) {

  if (suspended != this->suspended && !ignore_suspend) {
    this->suspended = suspended;

    // compte next_frame_date if the animation is being resumed
    if (!suspended) {
      uint32_t now = System::now();
      next_frame_date = now + get_frame_delay();
      blink_next_change_date = now;
    }
    else {
      blink_is_sprite_visible = true;
    }

    // Also suspend or resumed the transition effect and the movement if any.
    Transition* transition = get_transition();
    if (transition != NULL) {
      transition->set_suspended(suspended);
    }

    Movement* movement = get_movement();
    if (movement != NULL) {
      movement->set_suspended(suspended);
    }
  }
}
Exemple #2
0
/**
 * @brief Makes a movement accessible from the script.
 *
 * If the movement is already accessible from this script,
 * this function returns the already known handle.
 *
 * @param movement the movement to make accessible
 * @return a handle that can be used by scripts to refer to this movement
 */
int Script::create_movement_handle(Movement &movement) {

  int handle = movement.get_unique_id();
  if (movements.find(handle) == movements.end()) {
    movements[handle] = &movement;
    unassigned_movements[handle] = &movement;
    movement.set_suspended(true); // suspended until it is assigned to an object
  }

  return handle;
}