zoukankan      html  css  js  c++  java
  • Working with Other Node Types II

    Working with Other Node Types II

      An SKCropNode object does not directly render content, like a sprite node. Instead, it alters the behavior of its children when they are rendered. A crop node crops out portions of the content rendered by the children.

      Listing 6-8 shows a simple use of a mask. This code loads a mask image from a texture in the app bundle. A portion of the scene’s content is then rendered, using the mask to prevent it from overdrawing the portion of the screen that the game uses to show controls.

      

      When the crop node is rendered, the mask is rendered before the descendants are drawn. Only the alpha component of the resulting mask is relevant. Any pixel in the mask with an alpha value of 0.05 or higher is rendered. All other pixels are cropped.

    Effect Nodes Apply Special Effects to Their Descendants

      An SKEffectNode object does not draw content of its own. Instead, each time a new frame is rendered using the effect node, the effect node follows these steps:

    1. Draws its children into a private framebuffer.
    2. Applies a Core Image effect to the private framebuffer. This stage is optional.
    3. Blends the contents of its private framebuffer into its parent’s framebuffer, using one of the standard sprite blend modes.
    4. Discards its private framebuffer.

      You’ve learned a lot about the SKScene class already, but you may not have noticed that it is a subclass of SKEffectNode. This means that any scene can apply a filter to the contents. Although applying filters can be very expensive—not all filters are well designed for interactive effects—experimentation can help you find some interesting ways to use filters.

      If the content of the effect node is static, you can set the node’s shouldRasterize property to YES. Setting this property causes the following changes in behavior:

    • The framebuffer is not discarded at the end of rasterization. This also means that more memory is being used by the effect node, and rendering may take slightly longer.
    • When a new frame is rendered, the framebuffer is rendered only if the content of the effect node’s descendants have changed.
    • Changing the Core Image filter’s properties no longer causes the framebuffer to automatically be updated. You can force it to be updated by setting the shouldRasterize property to NO.
  • 相关阅读:
    NPOI操作EXCEL
    几个英文的数学概念
    C#中将鼠标光标变为忙碌状态
    C#使用Linq to Sqlite
    SSM-SpringMVC-25:SpringMVC异常顶级之自定义异常解析器
    SSM-SpringMVC-24:SpringMVC异常高级之自定义异常
    SSM-SpringMVC-23:SpringMVC中初探异常解析器
    SSM-SpringMVC-22:SpringMVC中转发(forward)和重定向(redirect)
    SSM-SpringMVC-21:SpringMVC中处理器方法之返回值Object篇
    jQuery-01:on live bind delegate
  • 原文地址:https://www.cnblogs.com/tekkaman/p/3531834.html
Copyright © 2011-2022 走看看