コード例 #1
0
ファイル: DrawableAPI.cpp プロジェクト: ElAleyo/solarus
/**
 * \brief Destroys from Lua all drawable objects created
 * by this script.
 */
void LuaContext::destroy_drawables() {

  std::set<Drawable*>::iterator it;
  for (it = drawables.begin(); it != drawables.end(); ++it) {
    Drawable* drawable = *it;
    drawable->decrement_refcount();
    if (drawable->get_refcount() == 0) {
      delete drawable;
    }
  }
  drawables.clear();
  drawables_to_remove.clear();
}
コード例 #2
0
ファイル: DrawableAPI.cpp プロジェクト: ElAleyo/solarus
/**
 * \brief Updates all drawable objects created by this script.
 */
void LuaContext::update_drawables() {

  // Update all drawables.
  std::set<Drawable*>::iterator it;
  for (it = drawables.begin(); it != drawables.end(); ++it) {
    Drawable* drawable = *it;
    if (has_drawable(drawable)) {
      drawable->update();
    }
  }

  // Remove the ones that should be removed.
  for (it = drawables_to_remove.begin(); it != drawables_to_remove.end(); ++it) {
    Drawable* drawable = *it;
    drawables.erase(drawable);
    drawable->decrement_refcount();
    if (drawable->get_refcount() == 0) {
      delete drawable;
    }
  }
  drawables_to_remove.clear();
}