本文整理汇总了C++中sf::RenderTarget::GetDefaultView方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderTarget::GetDefaultView方法的具体用法?C++ RenderTarget::GetDefaultView怎么用?C++ RenderTarget::GetDefaultView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::RenderTarget
的用法示例。
在下文中一共展示了RenderTarget::GetDefaultView方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fmod
void fff::bg::Run(sf::RenderTarget &rendertarget, sf::Uint32 time, float height){
float ftime = time/1000.f;
height = fmod(height*ratioy, 480.f);
this->setPositionY(-height);
sf::Vector2f pos = sprites[0].GetPosition();
//std::cout << "pos.x: " << pos.x << std::endl;
if (velx > 0.f && pos.x > 0.f){
this->setPositionX(-640.f);
}else if (velx < 0.f && pos.x < -640.f){
this->setPositionX(0.f);
}
rendertarget.SetView( rendertarget.GetDefaultView() );
for(int i = 0; i < 4; i += 1){
sprites[i].Move(ftime * velx, 0.f);
rendertarget.Draw(sprites[i]);
}
}
示例2: render
void GridPoint::render(sf::RenderTarget &tgt) {
// We don't want the circle to scale with the image, so we have to break out of
// the current View and compute the position manually.
const sf::View &view = tgt.GetView();
sf::FloatRect rect = view.GetRect();
float xtrans = rect.Left + (x * tgt.GetWidth() / rect.GetWidth());
float ytrans = rect.Top + (y * tgt.GetHeight() / rect.GetHeight());
tgt.SetView( tgt.GetDefaultView() );
sf::Shape circle = sf::Shape::Circle(xtrans, ytrans, 5,
sf::Color(0, 0, 0, 0),
1, sf::Color(255, 0, 0));
tgt.Draw(circle);
tgt.SetView(view);
}
示例3: if
void bange::layerimagetilemap::Process(sf::Uint32 time, sf::RenderTarget &rendertarget, std::map<const void *, int> &views, lua_State *vm){
std::map<const void *, int>::iterator aview;
bange::proxy *proxy = NULL;
bange::tile *tile = NULL;
bange::sprite *sprite = NULL;
for (int i = 0; i < processtiles.size(); i += 1){
lua_rawgeti(vm, LUA_REGISTRYINDEX, processtiles[i]);
proxy = static_cast<bange::proxy *>( lua_touserdata(vm, -1) );
proxy->behavior->Process(lua_gettop(vm), time, vm);
lua_pop(vm, 1);
tile = static_cast<bange::tile *>(proxy->object);
tile->Process(time, vm);
}
//Process the autoscroll
float ctime = (float)time / 1000.f;
if ( (flags & bange::layerimagetilemap::autoscrollx) == bange::layerimagetilemap::autoscrollx ){
xautoscrollx += velautoscrollx * ctime;
if ( fabs(xautoscrollx) > widthtilemap ){
xautoscrollx = 0.f;
}
}
if ( (flags & bange::layerimagetilemap::autoscrolly) == bange::layerimagetilemap::autoscrolly ){
yautoscrolly += velautoscrolly * ctime;
if ( fabs(yautoscrolly) > heighttilemap ){
yautoscrolly = 0.f;
}
}
//---
//Draw all the tiles in rendertexture
std::vector< std::vector<int> >::iterator arow;
std::vector<int>::iterator acol;
rendertexture.Clear();
for (arow = tiles.begin(); arow != tiles.end(); arow++){
for(acol = (*arow).begin(); acol != (*arow).end(); acol++){
if ( (*acol) == LUA_REFNIL){
continue;}
lua_rawgeti(vm, LUA_REGISTRYINDEX, (*acol));
proxy = static_cast<bange::proxy *>( lua_touserdata(vm, -1) );
tile = static_cast<bange::tile *>(proxy->object);
lua_pop(vm, 1);//proxy
if (tile->sprite == LUA_REFNIL){
continue;}
lua_rawgeti(vm, LUA_REGISTRYINDEX, tile->sprite);
proxy = static_cast<bange::proxy *>( lua_touserdata(vm, -1) );//Reuse proxy is safe
lua_pop(vm, 1);//proxy sprite
sprite = static_cast<bange::sprite *>(proxy->object);
rendertexture.Draw(*sprite);
}
}
rendertexture.Display();
//Now draw the tilemap's sprite with each view
sf::Vector2f opos = this->sprite.GetPosition();
rendertarget.SetView( rendertarget.GetDefaultView() );
for (aview = views.begin(); aview != views.end(); aview++){
const bange::view *view = static_cast<const bange::view *>(aview->first);
sf::Vector2f center = view->GetCenter();
sf::Vector2f size = view->GetSize();
float startxview = center.x-size.x/2.f;
float startyview = center.y-size.y/2.f;
rendertarget.SetView(*view);
//Draw the sprite with the tilemap rendered.
this->sprite.SetTexture(rendertexture.GetTexture());
//What...
if (flags == 0){
rendertarget.Draw(this->sprite);
}
else if ((flags & bange::layerimagetilemap::repeatx) == bange::layerimagetilemap::repeatx \
&& (flags & bange::layerimagetilemap::repeaty) != bange::layerimagetilemap::repeaty){
float x = -(int(center.x * velx + xautoscrollx) % (int)widthtilemap) + startxview - widthtilemap;
float posrepeatx = vely * center.y;
this->sprite.SetY(posrepeatx + opos.y);
for (; x < startxview+size.x; x += widthtilemap){
this->sprite.SetX(x);
rendertarget.Draw(this->sprite);
}
}
else if ((flags & bange::layerimagetilemap::repeaty) == bange::layerimagetilemap::repeaty \
&& (flags & bange::layerimagetilemap::repeatx) != bange::layerimagetilemap::repeatx){
float y = -(int(center.y * vely + yautoscrolly) % (int)heighttilemap) + startyview - heighttilemap;
float posrepeaty = velx * center.x;
this->sprite.SetX(posrepeaty + opos.x);
for (; y < startyview+size.y; y += heighttilemap){
this->sprite.SetY(y);
rendertarget.Draw(this->sprite);
}
}
else if ((flags & bange::layerimagetilemap::repeatx) == bange::layerimagetilemap::repeatx \
&& (flags & bange::layerimagetilemap::repeaty) == bange::layerimagetilemap::repeaty){
float y = -(int(center.y * vely + yautoscrolly) % (int)heighttilemap) + startyview - heighttilemap;
for(; y < startyview+size.y; y += heighttilemap){
this->sprite.SetY(y);
for (float x = -(int(center.x * velx + xautoscrollx) % (int)widthtilemap) + startxview - widthtilemap; x < startxview+size.x; x += widthtilemap){
this->sprite.SetX(x);
rendertarget.Draw(this->sprite);
}
}
}
this->sprite.SetPosition(opos);
}
//.........这里部分代码省略.........