• SKAction


    [SKAction]

     1、Every action is an opaque object that describes a change you want to make to the scene. All actions are implemented by the SKAction class; there are no visible subclasses. 

     2、Actions can either be instantaneous or non-instantaneous:

    • An instantaneous action starts and completes in a single frame of animation. For example, an action to remove a node from its parent is an instantaneous action because a node can’t be partially removed. Instead, when the action executes, the node is removed immediately.

    • A non-instantaneous action has a duration over which it animates its effects. When executed, the action is processed in each frame of animation until the action completes.

     3、Tip: Because actions are effectively immutable objects, you can run the same action safely on multiple nodes in the tree at the same time. For this reason, if you have an action that is used repeatedly in your game, create a single instance of the action and then reuse it whenever you need a node to execute it.

     4、If a node is running any actions, its hasActions property returns YES.

     5、Because action processing is tied to the scene, actions are processed only when the node is part of a presented scene’s node tree. You can take advantage of this feature by creating a node and assigning actions to it, but waiting until later to add the node to the scene. Later, when the node is added to the scene, it begins executing its actions immediately.

     6、Canceling Running Actions

      To cancel actions that a node is running, call its removeAllActions method. All actions are removed from the node immediately. If a removed action had a duration, any changes it already made to the node remain intact, but further changes are not executed.

     7、Receiving a Callback when an Action Completes

      The runAction:completion: method is identical to the runAction: method, but after the action completes, your block is called. This callback is only called if the action runs to completion. If the action is removed before it completes, the completion handler is never called.

     8、Using Named Actions for Precise Control over Actions

      If you need to see whether a particular action is executing or remove a specific action, you must use named actions.

      The following key-based methods are available: 

    • runAction:withKey: method to run the action. If an action with the same key is already executing, it is removed before the new action is added.

    • actionForKey: method to determine if an action with that key is already running.

    • removeActionForKey: method to remove the action.

     9、Repeating Actions Execute Another Action Multiple Times

      

      

     10、Configuring Action Timing

    • Normally, an animated action runs linearly. You can use an action’s timingMode property to choose a nonlinear timing mode for an animation. For example, you can have the action start quickly and then slow down over the remainder of the run.

    • An action’s speed property changes the rate at which an animation plays. You can speed up or slow down an animation from its default timing.

      A speed value of 1.0 is the normal rate. If you set an action’s speed property to 2.0, when the action is executed by a node, it plays twice as fast. To pause the action, set the value to 0.

      If you adjust the speed of an action that contains other actions (such as a group, sequence, or repeating action), the rate is applied to the actions contained within. The enclosed actions are also affected by their own speed property.

    • A node’s speed property has the same effect as the action’s speed property, but the rate is applied to all actions processed by the node or by any of the node’s descendants in the scene tree.

      Sprite Kit determines the rate at which an animation applies by finding all of the rates that apply to the action and multiplying them.

     11、Tips for Working with Actions   

      following tips might be useful:

    • A node’s userData property

    • The parent node’s userData property, if dozens of nodes share the same actions and the same parent

    • The scene’s userData property for actions shared by multiple nodes throughout the scene

      

  • 相关阅读:
    JavaScript 学习笔记 事件二
    auto_ptr
    POJ2299 UltraQuickSort(逆序对个数)
    2016年11月2日22:28:14
    将sql server中的数据倒入Excel(c#)
    线段树成段更新裸题POJ3468
    线段树成断更新裸题hdu1698 Just a Hook
    POJ2828 思维难度较好的一道线段树
    < 弱牛刷贪心给JerryDung&qiuwei大神Orz>最大乘积
    NOIP 2008 传纸条题解[双线程DP]
  • 原文地址:https://www.cnblogs.com/tekkaman/p/3583142.html
Copyright © 2020-2023  润新知