/** * \brief Sets the collision modes of this detector. * \param collision_modes the detector's collision modes * (can be an OR combination of collision modes) */ void Detector::set_collision_modes(int collision_modes) { if (collision_modes & COLLISION_SPRITE) { enable_pixel_collisions(); } this->collision_modes = collision_modes; }
/** * \brief Sets the map. * * Warning: when this function is called during the map initialization, * the current map of the game is still the old one. * * \param map The map. */ void Enemy::set_map(Map& map) { Detector::set_map(map); if (is_enabled()) { initialize(); enable_pixel_collisions(); } if (map.is_loaded()) { // We are not during the map initialization phase. restart(); } }
/** * \copydoc MapEntity::notify_created */ void Enemy::notify_created() { Detector::notify_created(); // At this point, enemy:on_created() was called. enable_pixel_collisions(); // Give sprites their initial direction. int initial_direction = get_direction(); std::vector<Sprite*>::const_iterator it; for (it = get_sprites().begin(); it != get_sprites().end(); it++) { (*it)->set_current_direction(initial_direction); } if (is_enabled()) { restart(); } }