本文整理汇总了C++中sf::View::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ View::getSize方法的具体用法?C++ View::getSize怎么用?C++ View::getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::View
的用法示例。
在下文中一共展示了View::getSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: originalWidth
RuntimeCamera::RuntimeCamera(sf::View & view) :
originalWidth(view.getSize().x),
originalHeight(view.getSize().y),
angle(0),
zoomFactor(1)
{
sfmlView = view;
}
示例2: setView
void LightSystem::setView(const sf::View& view)
{
_renderTexture.create(view.getSize().x,view.getSize().y);
_buffer.create(view.getSize().x,view.getSize().y);
_sprite.setTexture(_renderTexture.getTexture(),true);
_bufferSprite.setTexture(_buffer.getTexture(),true);
}
示例3: Drawbackground
void Map::Drawbackground(sf::View& ViewRef, E_Ground Ground)
{
int MinX, MaxX, MinY, MaxY;
if (WCR.inMapMaker)
{
MinX = (int)((WCR.MMPtr->MapMakrView.getCenter().x - (WCR.MMPtr->MapMakrView.getSize().x / 2)) / CellSize);
MaxX = (int)((WCR.MMPtr->MapMakrView.getCenter().x + (WCR.MMPtr->MapMakrView.getSize().x / 2)) / CellSize);
MinY = (int)((WCR.MMPtr->MapMakrView.getCenter().y - (WCR.MMPtr->MapMakrView.getSize().y / 2)) / CellSize);
MaxY = (int)((WCR.MMPtr->MapMakrView.getCenter().y + (WCR.MMPtr->MapMakrView.getSize().y / 2)) / CellSize);
}
else
{
MinX = (int)((ViewRef.getCenter().x - ViewRef.getSize().x / 2) / CellSize);
MaxX = (int)((ViewRef.getCenter().x + ViewRef.getSize().x / 2) / CellSize);
MinY = (int)((ViewRef.getCenter().y - ViewRef.getSize().y / 2) / CellSize);
MaxY = (int)((ViewRef.getCenter().y + ViewRef.getSize().y / 2) / CellSize);
}
WCR.LimitVariable(0, MapWidth - 1, MinX);
WCR.LimitVariable(0, MapWidth - 1, MaxX);
WCR.LimitVariable(0, MapHeight - 1, MinY);
WCR.LimitVariable(0, MapHeight - 1, MaxY);
for (int LID = 0; LID < BackgroundMatrix.size(); LID++)
{
if (WCR.MMPtr->OnlyShowThisLayer->IsActive() && WCR.inMapMaker && OrderedBackgroundLayers[LID] != WCR.MMPtr->curTileLayer)
continue;//Skip, not the layer we want.
int BL_ = BackgroundLayers[OrderedBackgroundLayers[LID]];
if (Ground == E_vForeground)
{
if (BL_ >= 0)
continue;//Not up to yet
}
else if (Ground == E_vMiddleground)
{
if (BL_ < 0)
break;//Gone past
if (BL_ != 0)
continue;//Go till found.
}
else if (Ground == E_vBackground)
{
if (BL_ < 1)
break;//Gone past
}
BL_ = OrderedBackgroundLayers[LID];
for (int i = MinX; i <= MaxX; i++)
for (int ii = MinY; ii <= MaxY; ii++)
{
if (BackgroundMatrix[BL_][i][ii].tileID != -1)//Not empty space.
{
WCR.MMPtr->TileSets[BackgroundMatrix[BL_][i][ii].tileSetID].Tiles[BackgroundMatrix[BL_][i][ii].tileID].setPosition(i * CellSize, ii * CellSize);
WCR.RenderRef.draw(WCR.MMPtr->TileSets[BackgroundMatrix[BL_][i][ii].tileSetID].Tiles[BackgroundMatrix[BL_][i][ii].tileID]);
}
}
}
}
示例4: logic
void Level::logic(sf::View& camera, unsigned int delta)
{
// Perform actions.
ActionInterface::logic(*this);
// Remove all dead entities.
for(list<Entity*>::iterator it = mDeadEntities.begin(); it != mDeadEntities.end(); it++)
mRemoveEntity(*it);
mDeadEntities.clear();
// Perform all entity logic.
for(list<Entity*>::iterator it = mEntities.begin(); it != mEntities.end(); it++)
(*it)->logic(*this, delta);
// If all items have been picked up, display a floating text and give a bonus.
if(mPickups.empty() && !mPickupAward)
{
addFloatingText("Level Cleared!", mPlayer.getPosition(), sf::Color::Yellow, 30);
distributeChangeScore(250);
mPickupAward = true;
}
// Perform floating text logic if the interval is passed.
if(mFloatingTextTimer.getTime() >= FLOATINGTEXT_TIMER_INTERVAL)
{
list<list<sf::Text>::iterator > removeList;
for(list<sf::Text>::iterator it = mFloatingTexts.begin(); it != mFloatingTexts.end(); ++it)
{
it->move(0, -FLOATINGTEXT_MOVE_STEP);
sf::Color c = it->getColor();
it->setColor(sf::Color(c.r, c.g, c.b, c.a - 3));
if(it->getColor().a == 0)
removeList.push_back(it);
}
for(list<list<sf::Text>::iterator >::iterator it = removeList.begin(); it != removeList.end(); ++it)
mFloatingTexts.erase(*it);
mFloatingTextTimer.start();
}
// Center the player on the screen.
camera.setCenter(mPlayer.getX() + (mPlayer.getWidth() / 2), mPlayer.getY() + (mPlayer.getHeight() / 2));
// Make sure that the camera doesn't go out of bounds.
sf::Vector2f center = camera.getCenter(),
half(camera.getSize().x / 2, camera.getSize().y / 2);
if(center.x - half.x < 0)
center.x = half.x;
if(center.x + half.x > mMap.getWidth())
center.x = mMap.getWidth() - half.x;
if(center.y - half.y < 0)
center.y = half.y;
if(center.y + half.y > mMap.getHeight())
center.y = mMap.getHeight() - half.y;
camera.setCenter(center);
}
示例5: getViewBounds
sf::FloatRect Helper::getViewBounds(const sf::View &view)
{
sf::FloatRect rt;
rt.left = view.getCenter().x - view.getSize().x/2;
rt.top = view.getCenter().y - view.getSize().y/2;
rt.width = view.getSize().x;
rt.height = view.getSize().y;
// std::cout << "View bounds" << rt.left << " " << rt.top << " " << rt.width << " " << rt.height << std::endl;
return rt;
}
示例6: isInsideView
inline bool isInsideView(const sf::View& targetView, const sf::FloatRect& boundingBox)
{
sf::FloatRect view(targetView.getCenter().x - targetView.getSize().x / 2.f,
targetView.getCenter().y - targetView.getSize().y / 2.f,
targetView.getSize().x,
targetView.getSize().y);
view.left -= VIEW_MARGIN;
view.top -= VIEW_MARGIN;
view.width += 2 * VIEW_MARGIN;
view.height += 2 * VIEW_MARGIN;
return view.intersects(boundingBox);
}
示例7: drawInViewSprites
void drawInViewSprites(sf::RenderWindow &window, sf::View &view,gameMap &map, std::vector< std::vector < sf::Sprite > > &sprites )
{
int leftX = floor((view.getCenter().x - view.getSize().x/2)/(map.getTile(0).getTileDims().x));
int rightX = ceil((view.getCenter().x + view.getSize().x/2)/(map.getTile(0).getTileDims().x));
int upY = floor((view.getCenter().y - view.getSize().y/2)/(map.getTile(0).getTileDims().y));
int downY = ceil((view.getCenter().y + view.getSize().y/2)/(map.getTile(0).getTileDims().y));
for(int y = upY; y<downY; y++)
{
for(int x = leftX; x<rightX; x++)
{
window.draw(sprites[y][x]);
}
}
}
示例8: update
void Interface::update(sf::View v)
{
//Positions the text relative to the view:
_text[CLOCK].setPosition(
((v.getCenter().x - (v.getSize().x / 2)) + 5), //X
((v.getCenter().y - (v.getSize().y / 2)) + 5)); //Y
_text[CLOCK_BESTTIME].setPosition(
(_text[CLOCK].getPosition().x), //X
(_text[CLOCK].getPosition().y + (_text[CLOCK].getGlobalBounds().height + 2))); //Y
_text[FPS].setPosition(
((v.getCenter().x + (v.getSize().x / 2)) - (_text[FPS].getGlobalBounds().width + 5)), //X
((v.getCenter().y + (v.getSize().y / 2)) - (_text[FPS].getGlobalBounds().height + 5))); //Y
}
示例9: BonusesPanelUpdate
void BonusesPanelUpdate(BonusesPanel& panel, sf::View view) {
float view_top = view.getCenter().y - view.getSize().y / 2.f;
float view_left = view.getCenter().x - view.getSize().x / 2.f;
panel.sprite.setPosition(view_left + PanelXPos, view_top + PanelYPos);
sf::FloatRect panel_box = panel.sprite.getGlobalBounds();
float cell_x = panel_box.left + PanelLeftBorderWidth;
float cell_y = panel_box.top + PanelTopBorderHeight;
float delimeter = 0;
for (size_t i = 0; i < panel.items->size(); i++) {
if (i != 0) {
delimeter = CellDelimeterHeight;
}
panel.items[0][i]->visual->sprite.setPosition(cell_x, cell_y + (CellHeight * i) + delimeter);
}
}
示例10: setView_Scroll
void setView_Scroll(sf::View &view, Character &character, gameMap &map)
{
float height = view.getSize().y;
float width = view.getSize().x;
float maxW = map.getWidth()*(map.getTile(0).getTileDims().x);
float maxH = map.getHeight()*(map.getTile(0).getTileDims().y);
float newX = 0;
float newY = 0;
if(character.getPosition().x < width/2)
{
newX = width/2;
}else if(character.getPosition().x > maxW - width/2)
{
newX = maxW - width/2;
}else
{
newX = round(character.getPosition().x);
}
if(character.getPosition().y < height/2)
{
newY = height/2;
}else if(character.getPosition().y > maxH - height/2)
{
newY = maxH - height/2;
}else
{
newY = round(character.getPosition().y);
}
view.setCenter(newX, newY);
}
示例11: DrawTheMinimap
void Minimap::DrawTheMinimap(sf::RenderWindow& window, Game& game, sf::View view)
{
if (ShouldBeUpdated)
{
UpdateTheMinimap(game.map);
ShouldBeUpdated = false;
}
MinimapSprite.setPosition(sf::Vector2f(window.getSize().x - 200.f, 50.f));
window.draw(MinimapSprite);
MinimapBackground.setPosition(sf::Vector2f(window.getSize().x - 200.f, 50.f));
window.draw(MinimapBackground);
for (int j = 0; j < game.MOBs.size(); j++)
{
AllyMobSprite.setPosition(sf::Vector2f(game.MOBs[j]->position.x * MINIMAP_WIDTH / MAP_DIM / TEX_DIM + window.getSize().x - 200.f - 4, game.MOBs[j]->position.y * MINIMAP_WIDTH / MAP_DIM / TEX_DIM + 50.f));
window.draw(AllyMobSprite);
}
for (int j = 0; j < game.structures.size(); j++)
{
AllyPlantSprite.setPosition(sf::Vector2f(game.structures[j].position.x * MINIMAP_WIDTH / MAP_DIM + window.getSize().x - 200.f - 4, game.structures[j].position.y * MINIMAP_WIDTH / MAP_DIM + 50.f));
window.draw(AllyPlantSprite);
}
sf::Vector2f ViewSize = view.getSize();
sf::Vector2f ViewCornerPosition = view.getCenter() - ViewSize / 2.0f;
MinimapFOVIndicator.setPosition(ViewCornerPosition.x * MINIMAP_WIDTH / MAP_DIM / TEX_DIM + window.getSize().x - 200.f, ViewCornerPosition.y * MINIMAP_WIDTH / MAP_DIM / TEX_DIM + 50.f);
MinimapFOVIndicator.setSize(sf::Vector2f(ViewSize.x * MINIMAP_WIDTH / MAP_DIM / TEX_DIM, ViewSize.y * MINIMAP_WIDTH / MAP_DIM / TEX_DIM));
window.draw(MinimapFOVIndicator);
}
示例12: getViewPosition
sf::Vector2f getViewPosition(sf::View& view)
{
sf::Vector2f center = view.getCenter();
sf::Vector2f half = view.getSize() / 2.0f;
return center - half;
}
示例13: rysuj_tekst
void rysuj_tekst( sf::RenderWindow & okno, sf::String _tresc, float x, float y )
{
double kamera_xHud = kamera.getCenter().x - kamera.getSize().x/2;
double kamera_yHud = kamera.getCenter().y - kamera.getSize().y/2;
tekst.setString( _tresc );
tekst.setPosition( kamera_xHud + x, kamera_yHud + y );
okno.draw( tekst );
}
示例14: aktualizuj_hud
void aktualizuj_hud()
{
aktualizuj_kamere();
double kamera_xHud = kamera.getCenter().x - kamera.getSize().x/2;
double kamera_yHud = kamera.getCenter().y - kamera.getSize().y/2;
ustaw_pozycjePaskaHp( kamera_xHud+10 , kamera_yHud + 5 );
ustaw_pozycjePaskaBonusu( kamera_xHud+30 , kamera_yHud + 440 );
aktualizuj_timer( 1 );
}
示例15: credits
void credits( sf::RenderWindow & okno )
{
sf::RectangleShape tlo_credits;
tlo_credits.setFillColor( sf::Color::Black );
tlo_credits.setPosition( kamera.getCenter().x - kamera.getSize().x/2,
kamera.getCenter().y - kamera.getSize().y/2 );
tlo_credits.setSize( sf::Vector2f( 640, 480 ) );
okno.draw( tlo_credits );
rysuj_tekst( okno, "Square War Alpha 0.9", 320, 20 );
rysuj_tekst( okno, "Autorzy:\nOlek Szatko\nMarcin Kula\nRafal Kot", 320, 240 );
}