当前位置: 首页>>代码示例>>C++>>正文


C++ Sprite函数代码示例

本文整理汇总了C++中Sprite函数的典型用法代码示例。如果您正苦于以下问题:C++ Sprite函数的具体用法?C++ Sprite怎么用?C++ Sprite使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Sprite函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sur

StarfieldBackgroundStars::StarfieldBackgroundStars (Type type) :
  sur(),
  x_pos(),
  y_pos(),
  x_add(),
  y_add()
{
  switch (type)
  {
    case SMALL_STAR:
      sur = Sprite("game/stars/small_star");
      break;
    case MIDDLE_STAR:
      sur = Sprite("game/stars/middle_star");
      break;
    case LARGE_STAR:
      sur = Sprite("game/stars/large_star");
      break;
  }

  x_pos = float(rand() % WorldObj::get_world()->get_width());
  y_pos = float(rand() % WorldObj::get_world()->get_height());

  x_add = static_cast<float>(rand() % 5) + 1.0f;
  y_add = 0.0f;
}
开发者ID:fsantanna,项目名称:pingus,代码行数:26,代码来源:starfield_background_stars.cpp

示例2: UIRoot

	void EditorApplication::OnStarted()
	{
		PushScopeEnterOnStack enterScope;

		o2Application.SetWindowCaption("o2 Editor");

		mUIRoot = mnew UIRoot();

		mBackground = mnew Sprite("ui/UI_Background.png");
		mBackSign = mnew Sprite("ui/UI_o2_sign.png");

		mConfig = mnew EditorConfig();
		mConfig->LoadConfigs();

		LoadUIStyle();

		mProperties = mnew Properties();
		mWindowsManager = mnew WindowsManager();
		mMenuPanel = mnew MenuPanel();
		mToolsPanel = mnew ToolsPanel();

		if (mConfig->mProjectConfig.mMaximized)
		{
			o2Application.Maximize();
		}
		else
		{
			Vec2I pos = mConfig->mProjectConfig.mWindowPosition;
			o2Application.SetWindowSize(mConfig->mProjectConfig.mWindowSize);
			o2Application.SetWindowPosition(pos);
			mConfig->mProjectConfig.mWindowPosition = pos;
		}

		OnResizing();
	}
开发者ID:zenkovich,项目名称:o2,代码行数:35,代码来源:EditorApplication.cpp

示例3: m_Player

PlayerUI::PlayerUI(const std::unique_ptr<Player>& player)
	: m_Player(player)
{
	m_PlayerHealth = Sprite(glm::vec3(20, Settings::Instance().PROJECTION_HEIGHT - 40, 0), glm::vec2(200, 20), glm::vec4(1, 0, 0, 1));
	m_Stamina = Sprite(glm::vec3(m_PlayerHealth.getPosition().x, m_PlayerHealth.getPosition().y - 30, 0), glm::vec2(200, 20), glm::vec4(0, 1, 0, 1));
	m_Crosshair = Sprite(glm::vec3(0, 0, 0), glm::vec2(32, 32), TextureManager::get("Textures/Player/crosshair.png"));
}
开发者ID:andrewj1990,项目名称:SandBox,代码行数:7,代码来源:PlayerUI.cpp

示例4: State

Pause_Menu::Pause_Menu(bool* keys0, ALLEGRO_EVENT_QUEUE* event_queue0):
	State(keys0, event_queue0)
{
	
	//************************
	// VARIABLES
	//************************

	selection = PAUSE_RESUME;

	//set keys ENTER and ESCAPE to false so no over-flow of information
	keys[KEY_ENTER] = false;
	keys[KEY_ESCAPE] = false;

	// these bools track keep track of when the up or down keys are actually being pressed
	key_up_still_pressed = false;
	key_down_still_pressed = false;


	// SPRITES
	//************
	pause_title = al_load_bitmap("images/pause_title.png");
	pause_resume = al_load_bitmap("images/pause_resume.png");
	pause_exit = al_load_bitmap("images/pause_exit.png");
	
	Pause_Title = Sprite(pause_title, 1, 1, 0, PAUSE_BUTTON_WIDTH, PAUSE_BUTTON_HEIGHT,
						PAUSE_BUTTON_X, PAUSE_TITLE_Y, 0, 0);
	Pause_Resume = Sprite(pause_resume, 1, 2, 0, PAUSE_BUTTON_WIDTH, PAUSE_BUTTON_HEIGHT, 
						PAUSE_BUTTON_X, PAUSE_RESUME_Y, 0, 0);
	Pause_Exit = Sprite(pause_exit, 1, 2, 0, PAUSE_BUTTON_WIDTH, PAUSE_BUTTON_HEIGHT,
						PAUSE_BUTTON_X, PAUSE_EXIT_Y, 0, 0);
}
开发者ID:koriantor,项目名称:Space-Invaders-mock-up,代码行数:32,代码来源:Pause_Menu.cpp

示例5: sdNew

void PlayerEntity::Load(MetadataObject &metadata, SceneNode *sprites)
{
	SpriteEntity::Load(metadata, sprites);
	pSprite->SetZ(-10);

	if (this->GetClassName() == "OptimistPlayer")
		pText = sdNew(Sprite(*static_cast<Sprite *>(sprites->GetChildByName("BallonOptimist"))));
	else if (this->GetClassName() == "RealistPlayer")
		pText = sdNew(Sprite(*static_cast<Sprite *>(sprites->GetChildByName("BallonRealist"))));
	else
		pText = sdNew(Sprite(*static_cast<Sprite *>(sprites->GetChildByName("BallonPessimist"))));

	pText->SetPosition(0, 0);
	pText->SetVisible(false);
	gScene->Add(pText);

	b2Vec2 customSize(32, 32);

	pBody = gPhysics->CreateBody(pSprite, &customSize);
	pBody->SetFixedRotation(true);
	pBody->GetFixtureList()->SetUserData(this);

	pInput->AddKeyboardListener(this);
	//fVelocity = 2.0f;
	vPlayerVectorDirection = VECTOR_ZERO;
}
开发者ID:ggj,项目名称:optimalus,代码行数:26,代码来源:playerentity.cpp

示例6: thumb_path

Sprite
Resource::load_thumb_sprite(const std::string& name)
{
  Pathname thumb_path("thumbnails/" + name + ".png", Pathname::DATA_PATH);
  if (thumb_path.exist())
  {
    log_info("Loading thumb from: %1%", thumb_path.str());
    return Sprite(thumb_path);
  }
  else
  {
    Surface surface = load_surface(name);
    if (!surface)
    {
      return Sprite();
    }
    else
    {
      Size thumb_size;
      if (surface.get_width() <= 48)
        thumb_size.width = surface.get_width();
      else
        thumb_size.width = 48;

      if (surface.get_height() <= 48)
        thumb_size.height = surface.get_height();
      else
        thumb_size.height = 48;

      Sprite sprite(surface.scale(thumb_size.width, thumb_size.height));
      sprite.set_hotspot(origin_top_left, (48 - sprite.get_width())/2, (48 - sprite.get_height())/2);
      return sprite;
    }
  }
}
开发者ID:AMDmi3,项目名称:pingus,代码行数:35,代码来源:resource.cpp

示例7: draw

 void GameStateOptions::draw(const double dt) {
     m_game.getGraphics().clear(sf::Color::Black);
     m_game.getGraphics().draw(&Sprite(m_background), BACKGROUND);
     m_game.getGraphics().draw(&Sprite(m_overlay), OVERLAY);
     m_gui.drawBuffer(GUI);
     m_game.getGraphics().display();
 }
开发者ID:dymani,项目名称:BrainBurst-Discontinued,代码行数:7,代码来源:GameStateOptions.cpp

示例8: DisplayWindow

FullScreen::FullScreen()
{
#ifdef WIN32
	clan::D3DTarget::set_current();
#else
	clan::OpenGLTarget::set_current();
#endif

	DisplayWindowDescription window_description;
	window_description.set_title("ClanLib FullScreen Example");
	window_description.set_size(Size(700, 600), true);
	window_description.set_allow_resize(true);

	window = DisplayWindow(window_description);

	sc.connect(window.sig_window_close(), clan::bind_member(this, &FullScreen::on_window_close));
	sc.connect(window.get_keyboard().sig_key_down(), clan::bind_member(this, &FullScreen::on_input_down));
	canvas = Canvas(window);

	spr_logo = Sprite(canvas, "../Basic2D/Resources/logo.png");
	spr_background = Sprite(canvas, "../../Display/Path/Resources/lobby_background2.png");

	font = clan::Font("tahoma", 24);
	game_time.reset();
}
开发者ID:doughdemon,项目名称:ClanLib,代码行数:25,代码来源:fullscreen.cpp

示例9: PinguAction

Jumper::Jumper (Pingu* p) :
  PinguAction(p),
  sprite()
{
  sprite.load(Direction::LEFT,  Sprite("pingus/player" + 
                                       pingu->get_owner_str() + "/jumper/left"));
  sprite.load(Direction::RIGHT, Sprite("pingus/player" + 
                                       pingu->get_owner_str() + "/jumper/right"));
}
开发者ID:AMDmi3,项目名称:pingus,代码行数:9,代码来源:jumper.cpp

示例10: background

AddOnMenu::AddOnMenu() :
  background(),
  ok_button()
{
  //background("core/menu/wood"),
  //blackboard("core/menu/blackboard"),

  background = Sprite("core/menu/blackboard");
  ok_button  = Sprite("core/start/ok");
}
开发者ID:AMDmi3,项目名称:pingus,代码行数:10,代码来源:addon_menu.cpp

示例11: Sprite

void
Sprite2DView::next_image(int i)
{
  if (directory.size() > 1)
  {
    if (new_sprite)
    {
      sprite = new_sprite;
      sprite.set_alpha(1.0f);
      new_sprite = Sprite();
      offset = 0;
      display_time = 0;
    }

    index = static_cast<unsigned int>(index + i) % directory.size();

    std::vector<Pathname> dir;

    if (shuffle)
      dir = shuffle_directory;
    else
      dir = directory;
      
    bool retry = false;

    do 
    {
      try 
      {
        new_sprite = Sprite(dir[index]);
        retry = false;
      } 
      catch(std::exception& e) 
      {
        // FIXME: won't work in combination with shuffle
        std::cout << "Error: " << e.what() << std::endl;
        std::cout << "Removing '" << directory[index] << "' from the list" << std::endl;
        directory.erase(directory.begin() + index);
        index = static_cast<unsigned int>(index) % directory.size();
        retry = true;
      }
    } 
    while (retry);

    ignore_delta = true;
    fadein = 0.0f;
    prepare_sprite(new_sprite);
    ConsoleLog << index << ": " << directory[index] << std::endl;
  }

  SpriteManager::current()->cleanup();
  SurfaceManager::current()->cleanup();
}
开发者ID:BackupTheBerlios,项目名称:windstille-svn,代码行数:53,代码来源:sprite2dview.cpp

示例12: left_sur

ConveyorBelt::ConveyorBelt(const FileReader& reader) :
  left_sur  (Sprite ("worldobjs/conveyorbelt_left")),
  right_sur (Sprite ("worldobjs/conveyorbelt_right")),
  middle_sur(Sprite ("worldobjs/conveyorbelt_middle")),
  pos(),
  width(),
  speed(),
  counter()
{
  reader.read_vector("position", pos);
  reader.read_int   ("width",    width);
  reader.read_float ("speed",    speed);
}
开发者ID:jcs12311,项目名称:pingus,代码行数:13,代码来源:conveyor_belt.cpp

示例13: Sprite

void Champignon::Create(glm::vec2 newPos, glm::vec2 newSpeed, std::vector<float> params)
{
    hurtTimer = 0.0f;

    pos = newPos;
    speed = newSpeed;

    startPos = pos.y;
    startSpeed = speed.x;

    if((int)params.size() < 1) throw Error("Error in champignon.cpp, line " + std::to_string(__LINE__));

    mode = params[0];

    exist = true;
    health = 1600 + 1280*mode;
    maxHealth = health;

    size = glm::vec2(64,80);
    body = Sprite(128,128);

    shootTimer = 60.0f + (float)(rand() % 120);
    mouthTimer = 0.0f;

    meteorTimer1 = 60.0f + (float)(rand() % 240);
    meteorTimer2 = 60.0f + (float)(rand() % 240);

    targetSpeed = glm::vec2();

    isBoss = true;

    deathTimer = 240.0f;
    isBeaten = false;

    power = 3;
    shieldPos1 = glm::vec2(-128,-64);
    shieldPos2 = glm::vec2(-128,-64);

    shieldSpeed1 = (rand() % 100)/100.0f + 0.5f;
    shieldSpeed2 = (rand() % 100)/100.0f + 0.5f;

    propeller = Sprite(128,128);
    thing = Sprite(128,128);
    thing.centerX = 64;
    thing.centerY = 64;

    shieldShootTimer1 = 60.0f + (float)(rand() % 60);
    shieldShootTimer2 = 60.0f + (float)(rand() % 60);

    phase = 0;
}
开发者ID:JaniNykanen,项目名称:Operation-Fungus-source,代码行数:51,代码来源:champignon.cpp

示例14: glGenTextures

////////////////////////////////////////////////////////////
/// Populate all the required game sprites
////////////////////////////////////////////////////////////
void MainClient::_populateSprites(void)
{
	//Weapon loading
	{
		std::string path;

		size_t sz = WeaponList.size();

		//resize texture vectors
		gs.bulletTex.resize(sz);
		gs.weaponTex.resize(sz);

		//Generate Textures
		glGenTextures(sz, &gs.bulletTex[0]);
		glGenTextures(sz, &gs.weaponTex[0]);

		//Populate sprites
		for(size_t k = 0; k < sz; k++){
			//Bullet
			{
				path = WeaponList[k] + "/bullet.png";
				if(!LoadTex(gs.bulletTex[k], path.c_str()))
					throw "Could not load bullet texture...";

				path = WeaponList[k] + "/bullet.sprh";
				gs.Bullet.push_back(Sprite(path.c_str(), gs.bulletTex[k]));
			}

			//Weapon
			{
				path = WeaponList[k] + "/weapon.png";
				if(!LoadTex(gs.weaponTex[k], path.c_str()))
					throw "Could not load weapon texture...";

				path = WeaponList[k] + "/weapon.sprh";
				gs.Weapon.push_back(Sprite(path.c_str(), gs.weaponTex[k]));
			}
		}
	}

	//Bullet, Hits, Explosions Sprites
	{
		gs.HitTexture.resize(2, 0);

		glGenTextures(2, &gs.HitTexture[0]);

		LoadTex(gs.HitTexture[1], "assets/explosions/default.png");
		gs.BulletHit.push_back(Sprite());
		gs.BulletHit.push_back(Sprite("assets/explosions/default.sprh", gs.HitTexture[1]));
	}
}
开发者ID:ballercat,项目名称:albatross,代码行数:54,代码来源:settings.cpp

示例15: create_window

FullScreen::FullScreen()
{
	// We support all display targets, in order listed here
	clan::D3DTarget::enable();
	clan::OpenGLTarget::enable();

	create_window();

	spr_logo = Sprite(canvas, "../Basic2D/Resources/logo.png");
	spr_background = Sprite(canvas, "../../Display/Path/Resources/lobby_background2.png");

	font = clan::Font("tahoma", 24);
	game_time.reset();
}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:14,代码来源:fullscreen.cpp


注:本文中的Sprite函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。