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


C++ RuntimeScene类代码示例

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


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

示例1: GetCameraY

float GD_API GetCameraY(RuntimeScene & scene, const gd::String & layer, std::size_t camera)
{
    if(camera >= scene.GetRuntimeLayer(layer).GetCameraCount())
        return 0.f;
    const sf::View & view = scene.GetRuntimeLayer(layer).GetCamera(camera).GetSFMLView();
    return view.getCenter().y;
}
开发者ID:victorlevasseur,项目名称:GD,代码行数:7,代码来源:RuntimeSceneCameraTools.cpp

示例2: ActDeleteCamera

/**
 * Delete a camera of a layer
 */
void GD_API ActDeleteCamera(RuntimeScene & scene, const gd::String & layerName, std::size_t camera)
{
    if(camera >= scene.GetRuntimeLayer(layerName).GetCameraCount())
        return;

    scene.GetRuntimeLayer(layerName).DeleteCamera(camera);
}
开发者ID:victorlevasseur,项目名称:GD,代码行数:10,代码来源:RuntimeSceneCameraTools.cpp

示例3: SetCameraAngle

void GD_API SetCameraAngle(RuntimeScene & scene, float newValue, const gd::String & layer, std::size_t camera)
{
    if(camera >= scene.GetRuntimeLayer(layer).GetCameraCount())
        return;

    return scene.GetRuntimeLayer(layer).GetCamera(camera).SetRotation(newValue);
}
开发者ID:victorlevasseur,项目名称:GD,代码行数:7,代码来源:RuntimeSceneCameraTools.cpp

示例4: CursorOnObject

bool RuntimeObject::CursorOnObject(RuntimeScene &scene, bool) {
  RuntimeLayer &theLayer = scene.GetRuntimeLayer(layer);
  auto insideObject = [this](const sf::Vector2f &pos) {
    return GetDrawableX() <= pos.x && GetDrawableX() + GetWidth() >= pos.x &&
           GetDrawableY() <= pos.y && GetDrawableY() + GetHeight() >= pos.y;
  };

  for (std::size_t cameraIndex = 0; cameraIndex < theLayer.GetCameraCount();
       ++cameraIndex) {
    const auto &view = theLayer.GetCamera(cameraIndex).GetSFMLView();

    sf::Vector2f mousePos = scene.renderWindow->mapPixelToCoords(
        scene.GetInputManager().GetMousePosition(), view);

    if (insideObject(mousePos)) return true;

    auto &touches = scene.GetInputManager().GetAllTouches();
    for (auto &it : touches) {
      sf::Vector2f touchPos =
          scene.renderWindow->mapPixelToCoords(it.second, view);
      if (insideObject(touchPos)) return true;
    }
  }

  return false;
}
开发者ID:Lizard-13,项目名称:GD,代码行数:26,代码来源:RuntimeObject.cpp

示例5: SetCameraZoom

void GD_API SetCameraZoom(RuntimeScene & scene, float newZoom, const gd::String & layer, std::size_t cameraNb)
{
    if(cameraNb >= scene.GetRuntimeLayer(layer).GetCameraCount())
        return;

    scene.GetRuntimeLayer(layer).GetCamera(cameraNb).SetZoom(newZoom);
}
开发者ID:victorlevasseur,项目名称:GD,代码行数:7,代码来源:RuntimeSceneCameraTools.cpp

示例6: CreateSFMLTexture

void GD_EXTENSION_API CreateSFMLTexture( RuntimeScene & scene, const gd::String & imageName, unsigned int width, unsigned int height, const gd::String & colorStr )
{
    //Get or create the texture in memory
    std::shared_ptr<SFMLTextureWrapper> newTexture;
    if ( !scene.GetImageManager()->HasLoadedSFMLTexture(imageName) )
        newTexture = std::shared_ptr<SFMLTextureWrapper>(new SFMLTextureWrapper);
    else
        newTexture = scene.GetImageManager()->GetSFMLTexture(imageName);

    //Get the color
    sf::Color color;
    bool colorIsOk = false;
    std::vector < gd::String > colors = colorStr.Split(U';');
    if ( colors.size() == 3 )
    {
        colorIsOk = true;
        color = sf::Color(colors[0].To<int>(), colors[1].To<int>(), colors[2].To<int>());
    }

    //Create the SFML image and the SFML texture
    if ( width != 0 && height != 0 && colorIsOk )
        newTexture->image.create(width, height, color);

    newTexture->texture.loadFromImage(newTexture->image); //Do not forget to update the associated texture

    scene.GetImageManager()->SetSFMLTextureAsPermanentlyLoaded(imageName, newTexture); //Otherwise
}
开发者ID:mateerladnam,项目名称:GD,代码行数:27,代码来源:PrimitiveDrawingTools.cpp

示例7: GetCameraHeight

double GD_API GetCameraHeight(RuntimeScene & scene, const gd::String & layer, std::size_t camera)
{
    if(camera >= scene.GetRuntimeLayer(layer).GetCameraCount())
        return 0.f;

    return scene.GetRuntimeLayer(layer).GetCamera(camera).GetHeight();
}
开发者ID:victorlevasseur,项目名称:GD,代码行数:7,代码来源:RuntimeSceneCameraTools.cpp

示例8: GetCameraViewportTop

double GD_API GetCameraViewportTop(RuntimeScene & scene, const gd::String & layer, std::size_t camera)
{
    if(camera >= scene.GetRuntimeLayer(layer).GetCameraCount())
        return 0.f;

    return scene.GetRuntimeLayer(layer).GetCamera(camera).GetSFMLView().getViewport().top;
}
开发者ID:victorlevasseur,项目名称:GD,代码行数:7,代码来源:RuntimeSceneCameraTools.cpp

示例9: SetWindowSize

void GD_API SetWindowSize( RuntimeScene & scene, int windowWidth, int windowHeight, bool useTheNewSizeForCameraDefaultSize)
{
    #if !defined(GD_IDE_ONLY)
    if ( useTheNewSizeForCameraDefaultSize ) //Change future cameras default size if wanted.
    {
        scene.game->SetDefaultWidth( windowWidth );
        scene.game->SetDefaultHeight( windowHeight );
    }

    //Avoid recreating every tick a new window if the size has not changed!
    if ( windowWidth == scene.renderWindow->getSize().x && windowHeight == scene.renderWindow->getSize().y )
        return;

    if ( scene.RenderWindowIsFullScreen() )
    {
        scene.renderWindow->create( sf::VideoMode( windowWidth, windowHeight, 32 ), scene.GetWindowDefaultTitle(), sf::Style::Close | sf::Style::Fullscreen );
        scene.ChangeRenderWindow(scene.renderWindow);
    }
    else
    {
        scene.renderWindow->create( sf::VideoMode( windowWidth, windowHeight, 32 ), scene.GetWindowDefaultTitle(), sf::Style::Close );
        scene.ChangeRenderWindow(scene.renderWindow);
    }
    #endif
}
开发者ID:cubemoon,项目名称:GD,代码行数:25,代码来源:RuntimeSceneTools.cpp

示例10: CenterCameraOnObjectWithLimits

void GD_API CenterCameraOnObjectWithLimits(RuntimeScene & scene, RuntimeObject * object, float left, float top, float right, float bottom, bool anticipateObjectMove, const gd::String & layer, std::size_t camera)
{
    if ( object == NULL ) return;

    if(camera >= scene.GetRuntimeLayer(layer).GetCameraCount())
        return;

    float xOffset = 0;
    float yOffset = 0;
    double elapsedTime = static_cast<double>(object->GetElapsedTime(scene)) / 1000000.0;
    if (anticipateObjectMove)
    {
        xOffset = object->TotalForceX() * elapsedTime;
        yOffset = object->TotalForceY() * elapsedTime;
    }

    RuntimeCamera & cam = scene.GetRuntimeLayer(layer).GetCamera(camera);

    double newX = std::min(std::max(object->GetDrawableX() + object->GetCenterX() + xOffset, left+cam.GetWidth()/2), right-cam.GetWidth()/2);
    double newY = std::min(std::max(object->GetDrawableY() + object->GetCenterY() + yOffset, top+cam.GetHeight()/2), bottom-cam.GetHeight()/2);

    cam.SetViewCenter(sf::Vector2f(newX, newY));

    return;
}
开发者ID:victorlevasseur,项目名称:GD,代码行数:25,代码来源:RuntimeSceneCameraTools.cpp

示例11: SetCameraSize

/**
 * Change the size of a camera and reset the zoom factor.
 */
void GD_API SetCameraSize( RuntimeScene & scene, const gd::String & layer, std::size_t cameraNb, float width, float height)
{
    if(cameraNb >= scene.GetRuntimeLayer(layer).GetCameraCount())
        return;

    scene.GetRuntimeLayer(layer).GetCamera(cameraNb).SetZoom(1);
    scene.GetRuntimeLayer(layer).GetCamera(cameraNb).SetSize(width, height);
}
开发者ID:victorlevasseur,项目名称:GD,代码行数:11,代码来源:RuntimeSceneCameraTools.cpp

示例12: SetCameraY

void GD_API SetCameraY(RuntimeScene & scene, float y, const gd::String & layer, std::size_t cameraId)
{
    if(cameraId >= scene.GetRuntimeLayer(layer).GetCameraCount())
        return;

    RuntimeCamera & camera = scene.GetRuntimeLayer(layer).GetCamera(cameraId);
    camera.SetViewCenter(sf::Vector2f(camera.GetViewCenter().x, y));
}
开发者ID:victorlevasseur,项目名称:GD,代码行数:8,代码来源:RuntimeSceneCameraTools.cpp

示例13: SetCameraViewport

void GD_API SetCameraViewport( RuntimeScene & scene,  const gd::String & layer, std::size_t cameraNb, float viewportLeft, float viewportTop, float viewportRight, float viewportBottom )
{
    if(cameraNb >= scene.GetRuntimeLayer(layer).GetCameraCount())
        return;

    RuntimeCamera & camera = scene.GetRuntimeLayer(layer).GetCamera(cameraNb);
    camera.SetViewport(viewportLeft, viewportTop, viewportRight, viewportBottom);
}
开发者ID:victorlevasseur,项目名称:GD,代码行数:8,代码来源:RuntimeSceneCameraTools.cpp

示例14: GetCameraViewportBottom

double GD_API GetCameraViewportBottom(RuntimeScene & scene, const gd::String & layer, std::size_t camera)
{
    if(camera >= scene.GetRuntimeLayer(layer).GetCameraCount())
        return 0.f;

    const sf::FloatRect & sfmlViewport = scene.GetRuntimeLayer(layer).GetCamera(camera).GetSFMLView().getViewport();

    return sfmlViewport.top+sfmlViewport.height;
}
开发者ID:victorlevasseur,项目名称:GD,代码行数:9,代码来源:RuntimeSceneCameraTools.cpp

示例15: GetCursorYPosition

double GD_API GetCursorYPosition(RuntimeScene &scene,
                                 const gd::String &layer,
                                 std::size_t camera) {
  if (scene.GetRuntimeLayer(layer).GetCameraCount() == 0) return 0;
  if (camera >= scene.GetRuntimeLayer(layer).GetCameraCount()) camera = 0;

  // Get view, and compute mouse position
  const sf::View &view =
      scene.GetRuntimeLayer(layer).GetCamera(camera).GetSFMLView();
  return scene.renderWindow
      ->mapPixelToCoords(scene.GetInputManager().GetMousePosition(), view)
      .y;
}
开发者ID:4ian,项目名称:GD,代码行数:13,代码来源:MouseTools.cpp


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