CCAction Class 和 CCActionInterval Class 和 CCActionMoveTo Class ---Cocos2D-Swift v3.3

CCAction Class Reference

Inherits from NSObject
Conforms to NSCopying
Declared in CCAction.h

Overview

CCAction is an abstract base class for all actions. Actions animate nodes by manipulating node properties over time such as position, rotation, scale and opacity.

CCaction是一个关于所有动作的基本类型。通过操纵node属性,比如位置,旋转,透明度,规模等,激活Nodes。

For more information see the Concepts:Actions article in the Developer Guide

Subclasses

The following actions inherit directly from CCAction and can be used “as is”:

These action subclasses are abstract base classes for instant and “over time” actions, see their references for more information:

Tasks

Creating an Action

Action Targets

Identifying an Action

  • tag property

Action Methods Implemented by Subclasses

Properties

originalTarget

The original target, since target can be nil.

原始目标,可以为nil。

@property (nonatomic, readonly, unsafe_unretained) id originalTarget

Declared In

CCAction.h

tag

The action tag. An identifier of the action.

动作标签,定义一个动作.

@property (nonatomic, readwrite, assign) NSInteger tag

Declared In

CCAction.h

target

The “target” is typically the node instance that received the [CCNode runAction:] message. The action will modify the target properties. The target will be set with the ‘startWithTarget’ method. When the ‘stop’ method is called, target will be set to nil.

"target”是典型的node实例,可以接收[CCNode runAction:] 方法。acition会定义target属性。target可以通过startWithTarget方法设置,当stop方法被调用时,target会被置为nil。

@property (nonatomic, readonly, unsafe_unretained) id target

Discussion

Warning: The target is ‘assigned’ (unsafe unretained), it is not ‘retained’ nor managed by ARC.

Declared In

CCAction.h

Class Methods

action

Creates and returns an action.

创建和返回一个action

+ (id)action

Return Value

The CCAction Object.

Discussion

Warning: If a CCAction subclass provides designated initializers you will have to use those over this one.

Declared In

CCAction.h

Instance Methods

init

Initializes and returns an action object.

初始化和返回一个action对象。

- (id)init

Return Value

An initialized CCAction Object.

Declared In

CCAction.h

isDone

Return YES if the action has finished.

如果action结束,返回YES。

- (BOOL)isDone

Return Value

Action completion status

动作完成状态。

Declared In

CCAction.h

startWithTarget:

Assigns a target to the action Called before the action is started.

分配一个target给action。这回在action开始之前被调用。

- (void)startWithTarget:(id)target

Parameters

target

Target to assign to action (weak reference).

Declared In

CCAction.h

step:

Steps the action. Called for every frame with step interval.

action的步骤。每一帧被调用,步骤间隔。

- (void)step:(CCTime)dt

Parameters

dt

Ellapsed interval since last step.

Discussion

Note: Do not override unless you know what you are doing.

Declared In

CCAction.h

stop

Stops the action Called after the action has finished. Will assign the internal target reference to nil. Note: You should never call this method directly. In stead use: [target stopAction:action]

停止一个action,action结束后被调用。会让内部的target置为nil。

你永远不应该直接调用这个方法。用[target stopAction:action]代替。

- (void)stop

Declared In

CCAction.h

update:

Updates the action with normalized value.

用规范化的值更新动作。

- (void)update:(CCTime)time

Parameters

time

Normalized action progress.

Discussion

For example: A value of 0.5 indicates that the action is 50% complete.

Declared In

CCAction.h

CCActionInterval Class Reference

Inherits from CCActionFiniteTime : CCAction : NSObject
Conforms to NSCopying
Declared in CCActionInterval.h

Overview

Abstract base class for interval actions. An interval action is an action that performs its task over a certain period of time.

关于间隔动作的抽象基本类。一个间隔动作是指一个动作在一段时间内完成整个过程。

Most CCActionInterval actions can be reversed or have their speed altered via the CCActionSpeed action.

大部分的CCActionInterval动作可以被逆转或者改变速率,通过CCActionSpeed动作。

Moving, Rotating, Scaling a Node

Animating a Node’s Visual Properties

Repeating and Reversing Actions

Creating Sequences of Actions

Easing the Duration of an Action

Animating custom float/double Properties

  • Tweening any node property (of type float or double):

Tasks

Other Methods

Creating a Interval Action

Reversing an Action

Methods implemented by Subclasses

Properties

elapsed

How many seconds had elapsed since the actions started to run.

自从动作被执行后过了多久。

@property (nonatomic, readonly) CCTime elapsed

Declared In

CCActionInterval.h

Class Methods

actionWithDuration:

Creates and returns an action interval object.

创建和返回一个action间隔对象。

+ (id)actionWithDuration:(CCTime)d

Parameters

d

Action interval.

Return Value

The CCActionInterval object.

Declared In

CCActionInterval.h

Instance Methods

initWithDuration:

Initializes and returns an action interval object.

- (id)initWithDuration:(CCTime)d

Parameters

d

Action interval.

Return Value

An initialized CCActionInterval Object.

Declared In

CCActionInterval.h

isDone

Returns YES if the action has finished.

- (BOOL)isDone

Return Value

Action finished status.

Declared In

CCActionInterval.h

reverse

Returns a reversed action.

- (CCActionInterval *)reverse

Return Value

Created reversed action.

Declared In

CCActionInterval.h

CCActionMoveTo Class Reference

Inherits from CCActionMoveBy : CCActionInterval : CCActionFiniteTime : CCAction : NSObject
Declared in CCActionInterval.h

Overview

This action moves the target to the position specified, these are absolute coordinates. Several CCMoveTo actions can be concurrently called, and the resulting movement will be the sum of individual movements.

Warning: Move actions shouldn’t be used to move nodes with a dynamic CCPhysicsBody as both the physics body and the action will alter the node’s position property, overriding each other’s changes. This leads to unpredictable behavior.

Tasks

Creating a Move Action

Class Methods

actionWithDuration:position:

Creates the action.

+ (id)actionWithDuration:(CCTime)duration position:(CGPoint)position

Parameters

duration

Action interval.

position

Absolute position to move to.

Return Value

New moveto action.

Declared In

CCActionInterval.h

Instance Methods

initWithDuration:position:

Initializes the action.

- (id)initWithDuration:(CCTime)duration position:(CGPoint)position

Parameters

duration

Action interval.

position

Absolute position to move to.

Return Value

New moveto action.

Declared In

CCActionInterval.h

时间: 2025-01-18 16:33:20

CCAction Class 和 CCActionInterval Class 和 CCActionMoveTo Class ---Cocos2D-Swift v3.3的相关文章

【Cocos2D研究院之游戏开发】

http://www.xuanyusong.com/archives/category/ios/cocos2d_game 分类目录归档:[Cocos2D研究院之游戏开发] 201211-19 Cocos2D研究院之打开全新ViewController与返回(八) 雨松MOMO [Cocos2D研究院之游戏开发] 围观5745次 17条评论          之前cocos2d的文章都是由魏凯同学维护,从今天开始我也会抽时间写点cocos2d的文章.最近在研究如何将IOS游戏与软件结合起来.通常游

cocos2dx基础篇(21)——基本动作CCAction

[唠叨] 在电影里,角色的运动就是动作.而在游戏里,动画就是角色的动作了.例如人物走动.跳跃.释放魔法,鸟儿飞翔,车轮滚动等.动作是游戏中不可或缺的重要组成部分,使得游戏更具魅力,变得丰富活力. cocos2dx引擎为我们提供了十分丰富的动作系统.在本节主要讲讲cocos2dx动作系统中最基本的动作. 本节内容比较多,需要慢慢消化-- [致谢] http://gl.paea.cn/contents/fdb2fb923944b2e6.html <Cocos2D-X游戏开发技术精解>刘建卓 著(别

cocos2dx扩展CCAction实现精灵抛物线运动

在不使用物理引擎的情况下,模拟物体在重力作用下的抛物线运动(忽略空气阻力).给出运动起始点位置,终点位置,重力加速度g,起始点的发射角作为参数. 先根据已知条件求出物体在x轴和y轴上的初速度,再根据公式f(t)=v0t+0.5*at2  求出运动轨迹. 类CCParabolaMove继承自CCAction. 1 CCParabolaMove* CCParabolaMove::create(const CCPoint& startPosition, const CCPoint& endPos

九、CCAction

之前介绍CCNode的时候说过,动作是指在特定时间内完成移动.缩放.旋转等操作的行为,节点可以通过运行动作来实现动画效果,这里的动作就是指CCAction对象,它有很多的子类,每个子类都封装了不同的动作效果. 先来看看CCAction的继承结构图 这里我省略了瞬时动作(CCActionInstant)和间隔动作(CCActionInterval)的子类,因为它们又包含了非常多的子类,待会再介绍它们的子类. CCAction和CCFiniteTimeAction都是抽象类,只定义了一些基本属性和方

cocos2D(九)---- CCAction

之前介绍CCNode的时候说过,动作是指在特定时间内完毕移动.缩放.旋转等操作的行为,节点能够通过执行动作来实现动画效果,这里的动作就是指CCAction对象,它有非常多的子类,每一个子类都封装了不同的动作效果. 先来看看CCAction的继承结构图 这里我省略了瞬时动作(CCActionInstant)和间隔动作(CCActionInterval)的子类,由于它们又包括了许多的子类.待会再介绍它们的子类. CCAction和CCFiniteTimeAction都是抽象类,仅仅定义了一些基本属性

Cocos2d-x学习笔记(六)CCAction分析

原创文章,转载请注明出处:http://blog.csdn.net/sfh366958228/article/details/38821319 前言 千呼万唤始出来,不知你与我的心情是否一样,终于是等到了CCAction的出场.如果说CCSprite是身体,那么CCAction一定就是灵魂,它的组合,让整个游戏充满活力,当然,充满活力的方法也并非仅此而已. 源码分析 class CC_DLL CCAction : public CCObject { public: CCAction(void);

cocos2d-x学习记录2——CCAction动作

CCAction能够使CCNode运动起来,能够呈现出多种多样的动作.这些动作能够改变其运动方向.形状.大小.旋转等. 同时,还可利用CCCallFunc.CCCallFuncN.CCCallFuncO.CCCallFuncND等函数实现回调. MyScene.h代码 1 #ifndef MyScene_H_H 2 #define MyScene_H_H 3 4 #include "cocos2d.h" 5 using namespace cocos2d; 6 7 class MySc

Cocos2d-X中的CCAction

CCAction用于创建各种动作 CCAction类及其子类的结构图: 程序实例1:创建一个延时性动作 #include "Action.h" CCScene* Action::scene() { CCScene* scene = CCScene::create(); Action* layer = Action::create(); scene->addChild(layer); return scene; } bool Action::init() { CCLayer::in

借助CCAction实现转盘抽奖

借助cocos2dx自带的CCMoveBY和CCEaseInOut实现目前流行的转盘抽奖效果. 创建一个辅助结点node_projection_,将转盘中被选中的精灵的序号pos与node_projection_的X坐标建立映射关系.当node_projection_执行CCMoveBY时,通过在每帧执行的回调函数roll_update(float dt)去刷新转盘中精灵的状态.而node_projuction_在X轴上的移动的距离决定了转盘最终高亮的位置. 1 void LayerRoll::