/**
 * \brief Calculates the bit fields representing the non-transparent pixels
 * of the images in this direction.
 *
 * This method has to be called if you want a sprite having this animations
 * to be able to detect pixel-perfect collisions.
 * If the pixel-perfect collisions are already enabled, this function does nothing.
 *
 * \param src_image the surface containing the animations
 */
void SpriteAnimationDirection::enable_pixel_collisions(Surface* src_image) {

  if (!are_pixel_collisions_enabled()) {
    for (int i = 0; i < get_nb_frames(); i++) {
      pixel_bits.push_back(new PixelBits(*src_image, frames[i]));
    }
  }
}
/**
 * \brief Calculates the bit fields representing the non-transparent pixels
 * of the images in this direction.
 *
 * This method has to be called if you want a sprite having this animations
 * to be able to detect pixel-perfect collisions.
 * If the pixel-perfect collisions are already enabled, this function does nothing.
 *
 * \param src_image the surface containing the animations
 */
void SpriteAnimationDirection::enable_pixel_collisions(Surface& src_image) {

  if (!are_pixel_collisions_enabled()) {
    for (int i = 0; i < get_nb_frames(); i++) {
      pixel_bits.emplace_back(src_image, frames[i]);
    }
  }
}
Example #3
0
/**
 * \brief Enables the pixel-perfect collision detection for these animations.
 */
void SpriteAnimationSet::enable_pixel_collisions() {

  if (!are_pixel_collisions_enabled()) {

    for (auto& kvp: animations) {
      kvp.second.enable_pixel_collisions();
    }
  }
}