• Runtimes
  • Few runtime questions

Hi again,

Would you please help me with this:

I have a full scene where background is part of the single animation, e.g. a skeleton is sitting on a chair, where chair and the room is a background.

In runtime i want to achieve the following:
character takes full height of the screen, background is proportional with character, but is clipped on sides if needed to take full width and height.

  • Misaki ответили на это сообщение.
    Related Discussions
    ...

    To achieve the effect where your character takes the full height of the screen and the background is proportional but clipped on the sides, you can use a viewport approach similar to what is described in the Spine Player context. The player acts as a viewport, and you can adjust the zoom level to ensure the character fills the screen height. This will naturally clip the background on the sides if it extends beyond the screen width. You can calculate the necessary scale factor based on the character's height and the screen height, then apply this scale to both the character and the background to maintain proportionality.

    SamTyurenkov Which Spine runtime will you use? I'm not sure I have any advice to give you from a Spine spec point of view, since your question seems to be more of a problem with the way the skeleton is placed at runtime, but without knowing what runtime you plan to use anyway, I'm not sure what advice I can give you. I think Spinebot's answer is based on the assumption that you plan to use the Spine Web Player.

    • SamTyurenkov ответили на это сообщение.

      Misaki im making previews with web player, but for production it will be C++ runtime probably.

      Advice for both would be great

      The Spine Web Player automatically calculates the viewport based on the current animation, determining a rectangle that contains the rendered textures for that specific animation.
      The background, being part of your animation, is taken into account and will be included in the calculation of that rectangle.

      You can manually specify the viewport using the viewport configuration property. The x, y, width, and height properties are all in skeleton world coordinates, meaning x=0 and y=0 correspond to the skeleton world origin.

      Regarding the spine-cpp runtime, all our runtimes provide a Skeleton#getBounds method, which determines a rectangle that contains the skeleton in its current pose. Rendering-aware runtimes, such as the spine-player itself, typically use this method to calculate the bounds of the current animation.

      You could instantiate a skeleton, hide the attachments you don't want to include in the bounds calculation, and determine your desired viewport. This approach can also be applied to the web player.

      Alternatively, you could create an attachment in the editor that simulates your desired viewport and use that attachment in the runtime to easily determine the correct viewport.