Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ActionManager

!#en ActionManager is a class that can manage actions.
Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface, which uses this class's singleton object. But there are some cases where you might need to use this class.
Examples:

  • When you want to run an action where the target is different from a CCNode.
  • When you want to pause / resume the actions
    !#zh ActionManager 是可以管理动作的单例类。
    通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。
    但也有一些情况下,您可能需要使用这个类。
    例如:
    • 当你想要运行一个动作,但目标不是 CCNode 类型时。
    • 当你想要暂停/恢复动作时。
example

{@link cocos2d/core/CCActionManager/ActionManager.js}

Hierarchy

  • ActionManager

Index

Properties

Private _arrayTargets

_arrayTargets: HashElement[] = []

Private _currentTarget

_currentTarget: HashElement

Private _elementPool

_elementPool: HashElement[] = []

Private _hashTargets

_hashTargets: Map<any, any> = new Map()

Methods

Private deleteHashElement

  • deleteHashElement(element: any): boolean

Private getElement

  • getElement(target: object, paused: boolean): HashElement

Private putElement

Private removeActionAtIndex

  • removeActionAtIndex(index: any, element: any): void

removeActionByTag

  • removeActionByTag(tag: number, element: any, target?: Node): void

Private searchElementByTarget

addAction

  • addAction(action: Action, target: Node, paused: boolean): void
  • !#en Adds an action with a target.
    If the target is already present, then the action will be added to the existing target. If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target. When the target is paused, the queued actions won't be 'ticked'. !#zh 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。
    如果目标已存在,动作将会被直接添加到现有的节点中。
    如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。
    当目标状态的 paused 为 true,动作将不会被执行

    method

    addAction

    Parameters

    Returns void

getActionByTag

  • getActionByTag(tag: number, target: Node): Action | null
  • !#en Gets an action given its tag an a target. !#zh 通过目标对象和标签获取一个动作。

    method

    getActionByTag

    Parameters

    • tag: number
    • target: Node

    Returns Action | null

    return the Action with the given tag on success

getNumberOfRunningActionsInTarget

  • getNumberOfRunningActionsInTarget(target: Node): number
  • !#en Returns the numbers of actions that are running in a certain target.
    Composable actions are counted as 1 action.
    Example:

    • If you are running 1 Sequence of 7 actions, it will return 1.
    • If you are running 7 Sequences of 2 actions, it will return 7. !#zh 返回指定对象下所有正在运行的动作数量。
      组合动作被算作一个动作。
      例如:
      • 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。
      • 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。
    method

    getNumberOfRunningActionsInTarget

    Parameters

    Returns number

pauseAllRunningActions

  • pauseAllRunningActions(): Array<any>
  • !#en Pauses all running actions, returning a list of targets whose actions were paused. !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。

    method

    pauseAllRunningActions

    Returns Array<any>

    a list of targets whose actions were paused.

pauseTarget

  • pauseTarget(target: Node): void
  • !#en Pauses the target: all running actions and newly added actions will be paused. !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。

    method

    pauseTarget

    Parameters

    Returns void

pauseTargets

  • pauseTargets(targetsToPause: Array<any>): void

purgeSharedManager

  • purgeSharedManager(): void
  • !#en purges the shared action manager. It releases the retained instance.
    because it uses this, so it can not be static. !#zh 清除共用的动作管理器。它释放了持有的实例。
    因为它使用 this,因此它不能是静态的。

    method

    purgeSharedManager

    Returns void

removeAction

  • removeAction(action: Action): void

removeActionByTag

  • removeActionByTag(tag: number, target?: Node): void
  • !#en Removes an action given its tag and the target. !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。

    method

    removeActionByTag

    Parameters

    • tag: number
    • Optional target: Node

    Returns void

removeAllActions

  • removeAllActions(): void

removeAllActionsFromTarget

  • removeAllActionsFromTarget(target: Node): void
  • !#en Removes all actions from a certain target.
    All the actions that belongs to the target will be removed. !#zh 移除指定对象上的所有动作。
    属于该目标的所有的动作将被删除。

    method

    removeAllActionsFromTarget

    Parameters

    Returns void

resumeTarget

  • resumeTarget(target: Node): void
  • !#en Resumes the target. All queued actions will be resumed. !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。

    method

    resumeTarget

    Parameters

    Returns void

resumeTargets

  • resumeTargets(targetsToResume: Array<any>): void
  • !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call). !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。

    method

    resumeTargets

    Parameters

    • targetsToResume: Array<any>

    Returns void

update

  • update(dt: number): void

Generated using TypeDoc