cc 模块
Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。
类型
- Action
- ActionInstant
- ActionInterval
- ActionManager
- AffineTransform
- AlphaKey
- Animation
- Animation.EventType
- AnimationClip
- AnimationCurve
- AnimationState
- Asset
- AssetManager
- AudioClip
- audioEngine
- AudioSource
- BitmapFont
- BlendFunc
- BlockInputEvents
- BoxCollider
- BoxCollider3D
- BufferAsset
- BufferRange
- Burst
- Button
- CallbacksInvoker
- Camera
- Canvas
- CircleCollider
- Collider
- Collider.Box
- Collider.Circle
- Collider.Polygon
- Collider3D
- ColliderInfo
- CollisionManager
- Color
- ColorKey
- ColorOvertimeModule
- Component
- Component.EventHandler
- ConstantForce
- constructor
- ContainerStrategy
- ContentStrategy
- CurveRange
- debug
- Details
- Director
- DistanceJoint
- DynamicAtlasManager
- Easing
- EditBox
- EffectAsset
- EqualToFrame
- EqualToWindow
- Event
- Event.EventAcceleration
- Event.EventCustom
- Event.EventKeyboard
- Event.EventMouse
- Event.EventTouch
- EventTarget
- FiniteTimeAction
- Font
- ForceOvertimeModule
- Game
- geomUtils.Aabb
- geomUtils.Frustum
- geomUtils.intersect
- geomUtils.Line
- geomUtils.Obb
- geomUtils.Plane
- geomUtils.Ray
- geomUtils.Sphere
- geomUtils.Triangle
- Gradient
- GradientRange
- Graphics
- GraySpriteState
- IBaseShape
- IBoxShape
- ICollisionDetect
- ICollisionEvent
- IContactEquation
- Intersection
- IPhysicsWorld
- IQuatLike
- IRaycastOptions
- IRigidBody
- ISphereShape
- ITriggerEvent
- IVec3Like
- Joint
- JsonAsset
- Label
- LabelAtlas
- LabelOutline
- LabelShadow
- Layout
- Light
- LimitVelocityOvertimeModule
- loader
- LoadingItems
- macro
- Manifold
- ManifoldPoint
- MapUtils
- Mask
- Mat3
- Mat4
- Material
- MaterialVariant
- Mesh
- MeshRenderer
- misc
- MotionStreak
- MotorJoint
- MouseJoint
- Node
- Node.EventType
- NodePool
- OptimizedCurve
- OriginalContainer
- PageView
- PageViewIndicator
- ParticleAsset
- ParticleSystem
- ParticleSystem3D
- path
- Physics3DManager
- PhysicsBoxCollider
- PhysicsChainCollider
- PhysicsCircleCollider
- PhysicsCollider
- PhysicsContact
- PhysicsImpulse
- PhysicsManager
- PhysicsMaterial
- PhysicsPolygonCollider
- PhysicsRayCastResult
- PhysicsRayResult
- Playable
- PolygonCollider
- Prefab
- primitive.VertexData
- PrismaticJoint
- PrivateNode
- ProgressBar
- ProportionalToFrame
- ProportionalToWindow
- Quat
- Rect
- RenderComponent
- renderer
- RenderTexture
- ResolutionPolicy
- RevoluteJoint
- RichText
- RigidBody
- RigidBody3D
- RopeJoint
- RotationOvertimeModule
- SafeArea
- Scene
- SceneAsset
- Scheduler
- screen
- Scrollbar
- ScrollView
- ShapeModule
- Size
- SizeOvertimeModule
- SkeletonAnimation
- SkeletonAnimationClip
- SkinnedMeshRenderer
- Slider
- SphereCollider3D
- Sprite
- SpriteAtlas
- SpriteFrame
- SubContextView
- SwanSubContextView
- sys
- SystemEvent
- SystemEvent.EventType
- TextAsset
- Texture2D
- TextureAnimationModule
- TiledLayer
- TiledMap
- TiledMapAsset
- TiledObjectGroup
- TiledTile
- TMXImageLayerInfo
- TMXLayerInfo
- TMXMapInfo
- TMXObjectGroupInfo
- TMXTilesetInfo
- Toggle
- ToggleContainer
- ToggleGroup
- Touch
- TrailModule
- TTFFont
- Tween
- TypeScript
- url
- ValueType
- Vec2
- Vec3
- Vec4
- VelocityOvertimeModule
- VertexFormat
- VideoClip
- VideoPlayer
- View
- ViewGroup
- visibleRect
- WebView
- WeldJoint
- WheelJoint
- Widget
- WorldManifold
- WXSubContextView
枚举
- AnimationCurve.WrapMode
- audioEngine.AudioState
- Button.Transition
- Camera.ClearFlags
- debug.DebugMode
- EditBox.InputFlag
- EditBox.InputMode
- EditBox.KeyboardReturnType
- ERigidBodyType
- Flags
- geomUtils.enums
- Graphics.LineCap
- Graphics.LineJoin
- Label.CacheMode
- Label.HorizontalAlign
- Label.Overflow
- Label.Type
- Label.VerticalAlign
- Layout.AxisDirection
- Layout.HorizontalDirection
- Layout.ResizeMode
- Layout.Type
- Layout.VerticalDirection
- Light.ShadowType
- Light.Type
- macro.BlendFactor
- macro.ImageFormat
- macro.KEY
- macro.TextAlignment
- Mask.Type
- Material.BUILTIN_NAME
- MeshRenderer.ShadowCastingMode
- Node._LocalDirtyFlag
- PageView.Direction
- PageView.EventType
- PageView.SizeMode
- PageViewIndicator.Direction
- ParticleSystem.EmitterMode
- ParticleSystem.PositionType
- ParticleSystem3DAssembler.RenderMode
- ParticleSystem3DAssembler.Space
- PhysicsManager.DrawBits
- Prefab.OptimizationPolicy
- primitive.PolyhedronType
- ProgressBar.Mode
- RayCastType
- RenderTexture.DepthStencilFormat
- RigidBodyType
- Scrollbar.Direction
- ScrollView.EventType
- shapeModule.ArcMode
- shapeModule.EmitLocation
- shapeModule.ShapeType
- Slider.Direction
- Sprite.FillType
- Sprite.SizeMode
- Sprite.State
- Sprite.Type
- sys.NetworkType
- Texture2D.Filter
- Texture2D.PixelFormat
- Texture2D.WrapMode
- textureAnimationModule.Animation
- textureAnimationModule.Mode
- TiledMap.Orientation
- TiledMap.Property
- TiledMap.RenderOrder
- TiledMap.StaggerAxis
- TiledMap.TileFlag
- TiledMap.TMXObjectType
- trailModule.TextureMode
- trailModule.TrailMode
- VerticalTextAlignment
- VideoPlayer.EventType
- VideoPlayer.ResourceType
- WebView.EventType
- Widget.AlignMode
- WrapMode
索引
属性(properties)
ENGINE_VERSIONStringThe current version of Cocos2d being used....easingEasing这是一个 Easing 类实例。directorDirector导演类。gameGame这是一个 Game 类的实例,包含游戏主体信息并负责驱动游戏的游戏对象。assetManagerAssetManagerresourcesAssetManager.Bundlecc.resources 是一个 bundle,用于管理所有在 assets/resources 下的资源systemEventSystemEvent系统事件单例,方便全局使用viewViewcc.view 是全局的视图对象。winSizeSizecc.winSize 为当前的游戏窗口的大小。IntegerstringSpecify that the input value must be integer in Inspector....FloatstringIndicates that the elements in array should be type double.BooleanstringIndicates that the elements in array should be type boolean.StringstringIndicates that the elements in array should be type string.EPSILONnumberdynamicAtlasManagerDynamicAtlasManagermatrixArray
方法
easeIn创建 easeIn 缓动对象,由慢到快。easeOut创建 easeOut 缓动对象,由快到慢。easeInOut创建 easeInOut 缓动对象,慢到快,然后慢。easeExponentialIn创建 easeExponentialIn 缓动对象。easeExponentialOut创建 easeExponentialOut 缓动对象。easeExponentialInOut创建 easeExponentialInOut 缓动对象。easeSineIn创建 EaseSineIn 缓动对象。easeSineOut创建 EaseSineOut 缓动对象。easeSineInOut创建 easeSineInOut 缓动对象。easeElasticIn创建 easeElasticIn 缓动对象。easeElasticOut创建 easeElasticOut 缓动对象。easeElasticInOut创建 easeElasticInOut 缓动对象。easeBounceIn创建 easeBounceIn 缓动对象。easeBounceOut创建 easeBounceOut 缓动对象。easeBounceInOut创建 easeBounceInOut 缓动对象。easeBackIn创建 easeBackIn 缓动对象。easeBackOut创建 easeBackOut 缓动对象。easeBackInOut创建 easeBackInOut 缓动对象。easeBezierAction创建 easeBezierAction 缓动对象。easeQuadraticActionIn创建 easeQuadraticActionIn 缓动对象。easeQuadraticActionOut创建 easeQuadraticActionOut 缓动对象。easeQuadraticActionInOut创建 easeQuadraticActionInOut 缓动对象。easeQuarticActionIn创建 easeQuarticActionIn 缓动对象。easeQuarticActionOut创建 easeQuarticActionOut 缓动对象。easeQuarticActionInOut创建 easeQuarticActionInOut 缓动对象。easeQuinticActionIn创建 easeQuinticActionIn 缓动对象。easeQuinticActionOut创建 easeQuinticActionOut 缓动对象。easeQuinticActionInOut创建 easeQuinticActionInOut 缓动对象。easeCircleActionIn创建 easeCircleActionIn 缓动对象。easeCircleActionOut创建 easeCircleActionOut 缓动对象。easeCircleActionInOut创建 easeCircleActionInOut 缓动对象。easeCubicActionIn创建 easeCubicActionIn 缓动对象。easeCubicActionOut创建 easeCubicActionOut 缓动对象。easeCubicActionInOut创建 easeCubicActionInOut 缓动对象。show立即显示。hide立即隐藏。toggleVisibility显隐状态切换。removeSelf从父节点移除自身。destroySelf创建一个销毁自身的动作。flipXX轴翻转。flipYY轴翻转。place放置在目标位置。callFunc执行回调函数。setPointsPoints settercardinalSplineTo按基数样条曲线轨迹移动到目标位置。updatePositionupdate position of targetcardinalSplineBy按基数样条曲线轨迹移动指定的距离。catmullRomTo按 Catmull Rom 样条曲线轨迹移动到目标位置。catmullRomBy按 Catmull Rom 样条曲线轨迹移动指定的距离。sequence顺序执行动作,创建的动作将按顺序依次运行。repeat重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。repeatForever永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。spawn同步执行动作,同步执行一组动作。rotateTo旋转到目标角度,通过逐帧修改它的 angle 属性,旋转方向将由最短的角度决定。rotateBy旋转指定的角度。moveBy移动指定的距离。moveTo移动到目标位置。skewTo偏斜到目标角度。skewBy偏斜指定的角度。jumpBy用跳跃的方式移动指定的距离。jumpTo用跳跃的方式移动到目标位置。bezierBy按贝赛尔曲线轨迹移动指定的距离。bezierTo按贝赛尔曲线轨迹移动到目标位置。scaleTo将节点大小缩放到指定的倍数。scaleBy按指定的倍数缩放节点大小。blink闪烁(基于透明度)。fadeTo修改透明度到指定值。fadeIn渐显效果。fadeOut渐隐效果。tintTo修改颜色到指定值。tintBy按照指定的增量修改颜色。delayTime延迟指定的时间量。reverseTime反转目标动作的时间轴。targetedAction用已有动作和一个新的目标节点创建动作。speed修改目标动作的速率。follow追踪目标节点的位置。tweenerror输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。warn输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。log输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。rotate3DTo旋转到目标角度,通过逐帧修改它的 quternion 属性,旋转方向将由最短的角度决定。rotate3DBy旋转指定的 3D 角度。Class定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅类型定义。_isCCClassChecks whether the constructor is created by cc.ClassEnum定义一个枚举类型。getListhandleTouchesBeginhandleTouchesMovehandleTouchesEndhandleTouchesCancelgetSetOfTouchesEndOrCancelgetGlobalTouchCountGets the count of all currently valid touches.getGlobalTouchesGets global touches map, please do not modify the touches, otherwise all event listener will be affectedgetPreTouchsetPreTouchgetTouchByXYgetMouseEventgetPointByEventgetTouchesByEventregisterSystemEventupdateisValid检查该对象是否不为 null 并且尚未销毁。deserialize将 JSON 反序列化为对象实例。instantiate克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。findFinds a node by hierarchy path, the path is case-sensitive....color通过该方法来创建一个新的 Color/Color:method 对象。mat4通过该简便的函数进行创建 cc.Mat4 对象。quat通过该简便的函数进行创建 cc.Quat 对象。size创建一个 cc.Size 对象的帮助函数。rect该方法用来快速创建一个新的矩形。clampClamps a value between a minimum float and maximum float value.clamp01Clamps a value between 0 and 1.lerprandomrandomRangeReturns a floating-point random number between min (inclusive) and max (exclusive).randomRangeIntReturns a random integer between min (inclusive) and max (exclusive).pseudoRandomLinear congruential generator using Hull-Dobell Theorem.pseudoRandomRangeReturns a floating-point pseudo-random number between min (inclusive) and max (exclusive).pseudoRandomRangeIntReturns a pseudo-random integer between min (inclusive) and max (exclusive).nextPow2Returns the next power of two for the valuerepeatReturns float remainder for t / lengthrepeatReturns time wrapped in ping-pong moderepeatReturns ratio of a value within a given rangesignReturns -1, 0, +1 depending on sign of x.v2通过该简便的函数进行创建 cc.Vec2 对象。v3通过该简便的函数进行创建 cc.Vec3 对象。getsetreset
Details
属性(properties)
ENGINE_VERSION
The current version of Cocos2d being used.
Please DO NOT remove this String, it is an important flag for bug tracking.
If you post a bug to forum, please attach this flag.
| meta | description |
|---|---|
| 类型 | String |
| 定义于 | predefine.js:211 |
easing
这是一个 Easing 类实例。
| meta | description |
|---|---|
| 类型 | Easing |
| 定义于 | cocos2d/animation/easing.js:534 |
director
导演类。
| meta | description |
|---|---|
| 类型 | Director |
| 定义于 | cocos2d/core/CCDirector.js:1123 |
game
这是一个 Game 类的实例,包含游戏主体信息并负责驱动游戏的游戏对象。。
| meta | description |
|---|---|
| 类型 | Game |
| 定义于 | cocos2d/core/CCGame.js:894 |
assetManager
| meta | description |
|---|---|
| 类型 | AssetManager |
| 定义于 | cocos2d/core/asset-manager/CCAssetManager.js:804 |
resources
cc.resources 是一个 bundle,用于管理所有在 assets/resources 下的资源
| meta | description |
|---|---|
| 类型 | AssetManager.Bundle |
| 定义于 | cocos2d/core/asset-manager/CCAssetManager.js:811 |
systemEvent
系统事件单例,方便全局使用
| meta | description |
|---|---|
| 类型 | SystemEvent |
| 定义于 | cocos2d/core/event/system-event.js:200 |
view
cc.view 是全局的视图对象。
| meta | description |
|---|---|
| 类型 | View |
| 定义于 | cocos2d/core/platform/CCView.js:1542 |
winSize
cc.winSize 为当前的游戏窗口的大小。
| meta | description |
|---|---|
| 类型 | Size |
| 定义于 | cocos2d/core/platform/CCView.js:1551 |
Integer
Specify that the input value must be integer in Inspector. Also used to indicates that the elements in array should be type integer.
| meta | description |
|---|---|
| 类型 | string |
| 定义于 | cocos2d/core/platform/attribute.js:120 |
示例
// in cc.Class
member: {
default: [],
type: cc.Integer
}
// ES6 ccclass
Float
Indicates that the elements in array should be type double.
| meta | description |
|---|---|
| 类型 | string |
| 定义于 | cocos2d/core/platform/attribute.js:139 |
示例
// in cc.Class
member: {
default: [],
type: cc.Float
}
// ES6 ccclass
Boolean
Indicates that the elements in array should be type boolean.
| meta | description |
|---|---|
| 类型 | string |
| 定义于 | cocos2d/core/platform/attribute.js:164 |
示例
// in cc.Class
member: {
default: [],
type: cc.Boolean
}
// ES6 ccclass
String
Indicates that the elements in array should be type string.
| meta | description |
|---|---|
| 类型 | string |
| 定义于 | cocos2d/core/platform/attribute.js:182 |
示例
// in cc.Class
member: {
default: [],
type: cc.String
}
// ES6 ccclass
EPSILON
| meta | description |
|---|---|
| 类型 | number |
| 定义于 | cocos2d/core/value-types/utils.ts:13 |
dynamicAtlasManager
| meta | description |
|---|---|
| 类型 | DynamicAtlasManager |
| 定义于 | cocos2d/core/renderer/utils/dynamic-atlas/manager.js:267 |
matrix
| meta | description |
|---|---|
| 类型 | Array |
| 定义于 | cocos2d/core/3d/physics/cocos/utils/array-collision-matrix.ts:34 |
方法
easeIn
创建 easeIn 缓动对象,由慢到快。
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:35 |
参数列表
rateNumber
示例
action.easing(cc.easeIn(3.0));
easeOut
创建 easeOut 缓动对象,由快到慢。
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:58 |
参数列表
rateNumber
示例
action.easing(cc.easeOut(3.0));
easeInOut
创建 easeInOut 缓动对象,慢到快,然后慢。
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:81 |
参数列表
rateNumber
示例
action.easing(cc.easeInOut(3.0));
easeExponentialIn
创建 easeExponentialIn 缓动对象。
EaseExponentialIn 是按指数函数缓动进入的动作。
参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:109 |
示例
action.easing(cc.easeExponentialIn());
easeExponentialOut
创建 easeExponentialOut 缓动对象。
EaseExponentialOut 是按指数函数缓动退出的动作。
参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:135 |
示例
action.easing(cc.easeExponentialOut());
easeExponentialInOut
创建 easeExponentialInOut 缓动对象。
EaseExponentialInOut 是按指数函数缓动进入并退出的动作。
参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:161 |
示例
action.easing(cc.easeExponentialInOut());
easeSineIn
创建 EaseSineIn 缓动对象。
EaseSineIn 是按正弦函数缓动进入的动作。
参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:194 |
示例
action.easing(cc.easeSineIn());
easeSineOut
创建 EaseSineOut 缓动对象。
EaseSineIn 是按正弦函数缓动退出的动作。
参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:220 |
示例
action.easing(cc.easeSineOut());
easeSineInOut
创建 easeSineInOut 缓动对象。
EaseSineIn 是按正弦函数缓动进入并退出的动作。
参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:246 |
示例
action.easing(cc.easeSineInOut());
easeElasticIn
创建 easeElasticIn 缓动对象。
EaseElasticIn 是按弹性曲线缓动进入的动作。
参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:276 |
参数列表
periodNumber
示例
// example
action.easing(cc.easeElasticIn(3.0));
easeElasticOut
创建 easeElasticOut 缓动对象。
EaseElasticOut 是按弹性曲线缓动退出的动作。
参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:322 |
参数列表
periodNumber
示例
// example
action.easing(cc.easeElasticOut(3.0));
easeElasticInOut
创建 easeElasticInOut 缓动对象。
EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。
参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:362 |
参数列表
periodNumber
示例
// example
action.easing(cc.easeElasticInOut(3.0));
easeBounceIn
创建 easeBounceIn 缓动对象。
EaseBounceIn 是按弹跳动作缓动进入的动作。
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:434 |
示例
// example
action.easing(cc.easeBounceIn());
easeBounceOut
创建 easeBounceOut 缓动对象。
EaseBounceOut 是按弹跳动作缓动退出的动作。
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:451 |
示例
// example
action.easing(cc.easeBounceOut());
easeBounceInOut
创建 easeBounceInOut 缓动对象。
EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:476 |
示例
// example
action.easing(cc.easeBounceInOut());
easeBackIn
创建 easeBackIn 缓动对象。
easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:508 |
示例
// example
action.easing(cc.easeBackIn());
easeBackOut
创建 easeBackOut 缓动对象。
easeBackOut 快速移动超出目标,然后慢慢回到目标点。
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:534 |
示例
// example
action.easing(cc.easeBackOut());
easeBackInOut
创建 easeBackInOut 缓动对象。
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:564 |
示例
// example
action.easing(cc.easeBackInOut());
easeBezierAction
创建 easeBezierAction 缓动对象。
EaseBezierAction 是按贝塞尔曲线缓动的动作。
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:595 |
参数列表
p0Number The first bezier parameterp1Number The second bezier parameterp2Number The third bezier parameterp3Number The fourth bezier parameter
示例
// example
action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
easeQuadraticActionIn
创建 easeQuadraticActionIn 缓动对象。
EaseQuadraticIn是按二次函数缓动进入的动作。
参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:624 |
示例
//example
action.easing(cc.easeQuadraticActionIn());
easeQuadraticActionOut
创建 easeQuadraticActionOut 缓动对象。
EaseQuadraticOut 是按二次函数缓动退出的动作。
参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:651 |
示例
//example
action.easing(cc.easeQuadraticActionOut());
easeQuadraticActionInOut
创建 easeQuadraticActionInOut 缓动对象。
EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。
参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:678 |
示例
//example
action.easing(cc.easeQuadraticActionInOut());
easeQuarticActionIn
创建 easeQuarticActionIn 缓动对象。
EaseQuarticIn 是按四次函数缓动进入的动作。
参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:713 |
示例
//example
action.easing(cc.easeQuarticActionIn());
easeQuarticActionOut
创建 easeQuarticActionOut 缓动对象。
EaseQuarticOut 是按四次函数缓动退出的动作。
参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:740 |
示例
//example
action.easing(cc.QuarticActionOut());
easeQuarticActionInOut
创建 easeQuarticActionInOut 缓动对象。
EaseQuarticInOut 是按四次函数缓动进入并退出的动作。
参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:768 |
easeQuinticActionIn
创建 easeQuinticActionIn 缓动对象。
EaseQuinticIn 是按五次函数缓动进的动作。
参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:796 |
示例
//example
action.easing(cc.easeQuinticActionIn());
easeQuinticActionOut
创建 easeQuinticActionOut 缓动对象。
EaseQuinticOut 是按五次函数缓动退出的动作
参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:823 |
示例
//example
action.easing(cc.easeQuadraticActionOut());
easeQuinticActionInOut
创建 easeQuinticActionInOut 缓动对象。
EaseQuinticInOut是按五次函数缓动进入并退出的动作。
参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:851 |
示例
//example
action.easing(cc.easeQuinticActionInOut());
easeCircleActionIn
创建 easeCircleActionIn 缓动对象。
EaseCircleIn是按圆形曲线缓动进入的动作。
参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:882 |
示例
//example
action.easing(cc.easeCircleActionIn());
easeCircleActionOut
创建 easeCircleActionOut 缓动对象。
EaseCircleOut是按圆形曲线缓动退出的动作。
参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:909 |
示例
//example
actioneasing(cc.easeCircleActionOut());
easeCircleActionInOut
创建 easeCircleActionInOut 缓动对象。
EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。
参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:937 |
示例
//example
action.easing(cc.easeCircleActionInOut());
easeCubicActionIn
创建 easeCubicActionIn 缓动对象。
EaseCubicIn 是按三次函数缓动进入的动作。
参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:968 |
示例
//example
action.easing(cc.easeCubicActionIn());
easeCubicActionOut
创建 easeCubicActionOut 缓动对象。
EaseCubicOut 是按三次函数缓动退出的动作。
参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:995 |
示例
//example
action.easing(cc.easeCubicActionOut());
easeCubicActionInOut
创建 easeCubicActionInOut 缓动对象。
EaseCubicInOut是按三次函数缓动进入并退出的动作。
参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
| meta | description |
|---|---|
| 返回 | Object |
| 定义于 | cocos2d/actions/CCActionEase.js:1023 |
show
立即显示。
| meta | description |
|---|---|
| 返回 | ActionInstant |
| 定义于 | cocos2d/actions/CCActionInstant.js:102 |
示例
// example
var showAction = cc.show();
hide
立即隐藏。
| meta | description |
|---|---|
| 返回 | ActionInstant |
| 定义于 | cocos2d/actions/CCActionInstant.js:141 |
示例
// example
var hideAction = cc.hide();
toggleVisibility
显隐状态切换。
| meta | description |
|---|---|
| 返回 | ActionInstant |
| 定义于 | cocos2d/actions/CCActionInstant.js:180 |
示例
// example
var toggleVisibilityAction = cc.toggleVisibility();
removeSelf
从父节点移除自身。
| meta | description |
|---|---|
| 返回 | ActionInstant |
| 定义于 | cocos2d/actions/CCActionInstant.js:230 |
参数列表
isNeedCleanUpBoolean
示例
// example
var removeSelfAction = cc.removeSelf();
destroySelf
创建一个销毁自身的动作。
| meta | description |
|---|---|
| 返回 | ActionInstant |
| 定义于 | cocos2d/actions/CCActionInstant.js:270 |
示例
var destroySelfAction = cc.destroySelf();
flipX
X轴翻转。
| meta | description |
|---|---|
| 返回 | ActionInstant |
| 定义于 | cocos2d/actions/CCActionInstant.js:326 |
参数列表
flipBoolean Indicate whether the target should be flipped or not
示例
var flipXAction = cc.flipX(true);
flipY
Y轴翻转。
| meta | description |
|---|---|
| 返回 | ActionInstant |
| 定义于 | cocos2d/actions/CCActionInstant.js:381 |
参数列表
flipBoolean
示例
var flipYAction = cc.flipY(true);
place
放置在目标位置。
| meta | description |
|---|---|
| 返回 | ActionInstant |
| 定义于 | cocos2d/actions/CCActionInstant.js:444 |
参数列表
示例
// example
var placeAction = cc.place(cc.v2(200, 200));
var placeAction = cc.place(200, 200);
callFunc
执行回调函数。
| meta | description |
|---|---|
| 返回 | ActionInstant |
| 定义于 | cocos2d/actions/CCActionInstant.js:554 |
参数列表
示例
// example
// CallFunc without data
var finish = cc.callFunc(this.removeSprite, this);
// CallFunc with data
var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true);
setPoints
Points setter
| meta | description |
|---|---|
| 定义于 | cocos2d/actions/CCActionCatmullRom.js:226 |
参数列表
pointsArray
cardinalSplineTo
按基数样条曲线轨迹移动到目标位置。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionCatmullRom.js:236 |
参数列表
示例
//create a cc.CardinalSplineTo
var action1 = cc.cardinalSplineTo(3, array, 0);
updatePosition
update position of target
| meta | description |
|---|---|
| 定义于 | cocos2d/actions/CCActionCatmullRom.js:319 |
参数列表
newPosVec2
cardinalSplineBy
按基数样条曲线轨迹移动指定的距离。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionCatmullRom.js:340 |
参数列表
catmullRomTo
按 Catmull Rom 样条曲线轨迹移动到目标位置。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionCatmullRom.js:388 |
参数列表
示例
var action1 = cc.catmullRomTo(3, array);
catmullRomBy
按 Catmull Rom 样条曲线轨迹移动指定的距离。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionCatmullRom.js:437 |
参数列表
示例
var action1 = cc.catmullRomBy(3, array);
sequence
顺序执行动作,创建的动作将按顺序依次运行。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:439 |
参数列表
actionOrActionArrayFiniteTimeAction | FiniteTimeAction[]tempArrayFiniteTimeAction
示例
// example
// create sequence with actions
var seq = cc.sequence(act1, act2);
// create sequence with array
var seq = cc.sequence(actArray);
repeat
重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:617 |
参数列表
actionFiniteTimeActiontimesNumber
示例
// example
var rep = cc.repeat(cc.sequence(jump2, jump1), 5);
repeatForever
永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:726 |
参数列表
actionFiniteTimeAction
示例
// example
var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));
spawn
同步执行动作,同步执行一组动作。
| meta | description |
|---|---|
| 返回 | FiniteTimeAction |
| 定义于 | cocos2d/actions/CCActionInterval.js:841 |
参数列表
actionOrActionArrayFiniteTimeAction | FiniteTimeAction[]tempArrayFiniteTimeAction
示例
// example
var action = cc.spawn(cc.jumpBy(2, cc.v2(300, 0), 50, 4), cc.rotateBy(2, 720));
todo: It should be the direct use new
rotateTo
旋转到目标角度,通过逐帧修改它的 angle 属性,旋转方向将由最短的角度决定。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:948 |
参数列表
示例
// example
var rotateTo = cc.rotateTo(2, 61.0);
rotateBy
旋转指定的角度。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:1034 |
参数列表
示例
// example
var actionBy = cc.rotateBy(2, 360);
moveBy
移动指定的距离。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:1149 |
参数列表
示例
// example
var actionTo = cc.moveBy(2, cc.v2(windowSize.width - 40, windowSize.height - 40));
moveTo
移动到目标位置。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:1226 |
参数列表
示例
// example
var actionBy = cc.moveTo(2, cc.v2(80, 80));
skewTo
偏斜到目标角度。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:1320 |
参数列表
示例
// example
var actionTo = cc.skewTo(2, 37.2, -37.2);
skewBy
偏斜指定的角度。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:1395 |
参数列表
tNumber time in secondssxNumber sx skew in degrees for X axissyNumber sy skew in degrees for Y axis
示例
// example
var actionBy = cc.skewBy(2, 0, -90);
jumpBy
用跳跃的方式移动指定的距离。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:1522 |
参数列表
示例
// example
var actionBy = cc.jumpBy(2, cc.v2(300, 0), 50, 4);
var actionBy = cc.jumpBy(2, 300, 0, 50, 4);
jumpTo
用跳跃的方式移动到目标位置。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:1604 |
参数列表
示例
// example
var actionTo = cc.jumpTo(2, cc.v2(300, 300), 50, 4);
var actionTo = cc.jumpTo(2, 300, 300, 50, 4);
bezierBy
按贝赛尔曲线轨迹移动指定的距离。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:1740 |
参数列表
示例
// example
var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)];
var bezierForward = cc.bezierBy(3, bezier);
bezierTo
按贝赛尔曲线轨迹移动到目标位置。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:1809 |
参数列表
示例
// example
var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)];
var bezierTo = cc.bezierTo(2, bezier);
scaleTo
将节点大小缩放到指定的倍数。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:1895 |
参数列表
示例
// example
// It scales to 0.5 in both X and Y.
var actionTo = cc.scaleTo(2, 0.5);
// It scales to 0.5 in x and 2 in Y
var actionTo = cc.scaleTo(2, 0.5, 2);
scaleBy
按指定的倍数缩放节点大小。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:1945 |
参数列表
durationNumber duration in secondssxNumber sx scale parameter in XsyNumber | Null sy scale parameter in Y, if Null equal to sx
示例
// example without sy, it scales by 2 both in X and Y
var actionBy = cc.scaleBy(2, 2);
//example with sy, it scales by 0.25 in X and 4.5 in Y
var actionBy2 = cc.scaleBy(2, 0.25, 4.5);
blink
闪烁(基于透明度)。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:2031 |
参数列表
示例
// example
var action = cc.blink(2, 10);
fadeTo
修改透明度到指定值。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:2098 |
参数列表
示例
// example
var action = cc.fadeTo(1.0, 0);
fadeIn
渐显效果。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:2154 |
参数列表
durationNumber duration in seconds
示例
//example
var action = cc.fadeIn(1.0);
fadeOut
渐隐效果。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:2203 |
参数列表
dNumber duration in seconds
示例
// example
var action = cc.fadeOut(1.0);
tintTo
修改颜色到指定值。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:2287 |
参数列表
示例
// example
var action = cc.tintTo(2, 255, 0, 255);
tintBy
按照指定的增量修改颜色。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:2380 |
参数列表
示例
// example
var action = cc.tintBy(2, -127, -255, -127);
delayTime
延迟指定的时间量。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:2424 |
参数列表
dNumber duration in seconds
示例
// example
var delay = cc.delayTime(1);
reverseTime
反转目标动作的时间轴。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:2510 |
参数列表
actionFiniteTimeAction
示例
// example
var reverse = cc.reverseTime(this);
targetedAction
用已有动作和一个新的目标节点创建动作。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/actions/CCActionInterval.js:2598 |
参数列表
targetNodeactionFiniteTimeAction
speed
修改目标动作的速率。
| meta | description |
|---|---|
| 返回 | Action |
| 定义于 | cocos2d/actions/CCAction.js:372 |
参数列表
actionActionIntervalspeedNumber
示例
// change the target action speed;
var action = cc.scaleTo(0.2, 1, 0.6);
var newAction = cc.speed(action, 0.5);
follow
追踪目标节点的位置。
| meta | description |
|---|---|
| 返回 | Action | Null |
| 定义于 | cocos2d/actions/CCAction.js:566 |
参数列表
示例
// example
// creates the action with a set boundary
var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight));
node.runAction(followAction);
// creates the action with no boundary set
var followAction = cc.follow(targetNode);
node.runAction(followAction);
tween
| meta | description |
|---|---|
| 返回 | Tween |
| 定义于 | cocos2d/actions/tween.js:698 |
参数列表
targetObject the target to animate
error
输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。
- 在 Cocos Creator 中,错误信息显示是红色的。
- 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCDebug.js:114 |
参数列表
msgAny A JavaScript string containing zero or more substitution strings.substAny JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
warn
输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
- 在 Cocos Creator 中,警告信息显示是黄色的。
- 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCDebug.js:158 |
参数列表
msgAny A JavaScript string containing zero or more substitution strings.substAny JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
log
输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCDebug.js:188 |
参数列表
msgString | Any A JavaScript string containing zero or more substitution strings.substAny JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
rotate3DTo
旋转到目标角度,通过逐帧修改它的 quternion 属性,旋转方向将由最短的角度决定。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/core/3d/actions.js:90 |
参数列表
durationNumber duration in secondsdstAngleXNumber | Vec3 | Quat dstAngleX in degrees.dstAngleYNumber dstAngleY in degrees.dstAngleZNumber dstAngleZ in degrees.
示例
// example
var rotate3DTo = cc.rotate3DTo(2, cc.v3(0, 180, 0));
rotate3DBy
旋转指定的 3D 角度。
| meta | description |
|---|---|
| 返回 | ActionInterval |
| 定义于 | cocos2d/core/3d/actions.js:199 |
参数列表
durationNumber duration in secondsdeltaAngleXNumber | Vec3 deltaAngleX in degreesdeltaAngleYNumber deltaAngleY in degreesdeltaAngleZNumber deltaAngleZ in degrees
示例
// example
var actionBy = cc.rotate3DBy(2, cc.v3(0, 360, 0));
Class
定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅类型定义。
| meta | description |
|---|---|
| 返回 | Function |
| 定义于 | cocos2d/core/platform/CCClass.js:863 |
参数列表
optionsObjectnameString The class name used for serialization.extendsFunction The base class.ctorFunction The constructor.__ctor__Function The same as ctor, but less encapsulated.propertiesObject The property definitions.staticsObject The static members.mixinsFunction[]editorObject attributes for Component listed below.executeInEditModeBoolean Allows the current component to run in edit mode. By default, all components are executed only at runtime, meaning that they will not have their callback functions executed while the Editor is in edit mode.requireComponentFunction Automatically add required component as a dependency.menuString The menu path to register a component to the editors "Component" menu. Eg. "Rendering/Camera".executionOrderNumber The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after. The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected.disallowMultipleBoolean If specified to a type, prevents Component of the same type (or subtype) to be added more than once to a Node.playOnFocusBoolean This property is only available when executeInEditMode is set. If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.inspectorString Customize the page url used by the current component to render in the Properties.iconString Customize the icon that the current component displays in the editor.helpString The custom documentation URL
updateFunction lifecycle method for Component, see updatelateUpdateFunction lifecycle method for Component, see lateUpdateonLoadFunction lifecycle method for Component, see onLoadstartFunction lifecycle method for Component, see startonEnableFunction lifecycle method for Component, see onEnableonDisableFunction lifecycle method for Component, see onDisableonDestroyFunction lifecycle method for Component, see onDestroyonFocusInEditorFunction lifecycle method for Component, see onFocusInEditoronLostFocusInEditorFunction lifecycle method for Component, see onLostFocusInEditorresetInEditorFunction lifecycle method for Component, see resetInEditoronRestoreFunction for Component only, see onRestore_getLocalBoundsFunction for Component only, see _getLocalBounds
示例
// define base class
var Node = cc.Class();
// define sub class
var Sprite = cc.Class({
name: 'Sprite',
extends: Node,
ctor: function () {
this.url = "";
this.id = 0;
},
statics: {
// define static members
count: 0,
getBounds: function (spriteList) {
// compute bounds...
}
},
properties {
width: {
default: 128,
type: cc.Integer,
tooltip: 'The width of sprite'
},
height: 128,
size: {
get: function () {
return cc.v2(this.width, this.height);
}
}
},
load: function () {
// load this.url...
};
});
// instantiate
var obj = new Sprite();
obj.url = 'sprite.png';
obj.load();
_isCCClass
Checks whether the constructor is created by cc.Class
| meta | description |
|---|---|
| 返回 | Boolean |
| 定义于 | cocos2d/core/platform/CCClass.js:1029 |
参数列表
constructorFunction
Enum
定义一个枚举类型。
用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。
| meta | description |
|---|---|
| 返回 | object |
| 定义于 | cocos2d/core/platform/CCEnum.js:34 |
参数列表
objobject a JavaScript literal object containing enum names and values, or a TypeScript enum type
示例
// JavaScript:
var WrapMode = cc.Enum({
Repeat: -1,
Clamp: -1
});
// Texture.WrapMode.Repeat == 0
// Texture.WrapMode.Clamp == 1
// Texture.WrapMode[0] == "Repeat"
// Texture.WrapMode[1] == "Clamp"
var FlagType = cc.Enum({
Flag1: 1,
Flag2: 2,
Flag3: 4,
Flag4: 8,
});
var AtlasSizeList = cc.Enum({
128: 128,
256: 256,
512: 512,
1024: 1024,
});
// TypeScript:
// If used in TypeScript, just define a TypeScript enum:
enum Direction {
Up,
Down,
Left,
Right
}
// If you need to inspect the enum in Properties panel, you can call cc.Enum:
const {ccclass, property} = cc._decorator;
@ccclass
class NewScript extends cc.Component {
@property({
type: cc.Enum(Direction) // call cc.Enum
})
direction: Direction = Direction.Up;
}
getList
| meta | description |
|---|---|
| 返回 | Object[] |
| 定义于 | cocos2d/core/platform/CCEnum.js:90 |
参数列表
enumDefObject the enum type defined from cc.Enum
handleTouchesBegin
| meta | description |
|---|---|
| 定义于 | cocos2d/core/platform/CCInputManager.js:150 |
参数列表
touchesArray
handleTouchesMove
| meta | description |
|---|---|
| 定义于 | cocos2d/core/platform/CCInputManager.js:195 |
参数列表
touchesArray
handleTouchesEnd
| meta | description |
|---|---|
| 定义于 | cocos2d/core/platform/CCInputManager.js:234 |
参数列表
touchesArray
handleTouchesCancel
| meta | description |
|---|---|
| 定义于 | cocos2d/core/platform/CCInputManager.js:249 |
参数列表
touchesArray
getSetOfTouchesEndOrCancel
| meta | description |
|---|---|
| 返回 | Array |
| 定义于 | cocos2d/core/platform/CCInputManager.js:264 |
参数列表
touchesArray
getGlobalTouchCount
Gets the count of all currently valid touches.
| meta | description |
|---|---|
| 返回 | Unknown |
| 定义于 | cocos2d/core/platform/CCInputManager.js:299 |
getGlobalTouches
Gets global touches map, please do not modify the touches, otherwise all event listener will be affected
| meta | description |
|---|---|
| 返回 | Unknown |
| 定义于 | cocos2d/core/platform/CCInputManager.js:308 |
getPreTouch
| meta | description |
|---|---|
| 返回 | Touch |
| 定义于 | cocos2d/core/platform/CCInputManager.js:317 |
参数列表
touchTouch
setPreTouch
| meta | description |
|---|---|
| 定义于 | cocos2d/core/platform/CCInputManager.js:337 |
参数列表
touchTouch
getTouchByXY
| meta | description |
|---|---|
| 返回 | Touch |
| 定义于 | cocos2d/core/platform/CCInputManager.js:362 |
参数列表
getMouseEvent
| meta | description |
|---|---|
| 返回 | Event.EventMouse |
| 定义于 | cocos2d/core/platform/CCInputManager.js:379 |
参数列表
getPointByEvent
| meta | description |
|---|---|
| 返回 | Vec2 |
| 定义于 | cocos2d/core/platform/CCInputManager.js:397 |
参数列表
getTouchesByEvent
| meta | description |
|---|---|
| 返回 | Array |
| 定义于 | cocos2d/core/platform/CCInputManager.js:420 |
参数列表
registerSystemEvent
| meta | description |
|---|---|
| 定义于 | cocos2d/core/platform/CCInputManager.js:458 |
参数列表
elementHTMLElement
update
| meta | description |
|---|---|
| 定义于 | cocos2d/core/platform/CCInputManager.js:628 |
参数列表
dtNumber
isValid
检查该对象是否不为 null 并且尚未销毁。
当一个对象的 destroy 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 isValid 就会返回 false,而当前帧内 isValid 仍然会是 true。如果希望判断当前帧是否调用过 destroy,请使用 cc.isValid(obj, true),不过这往往是特殊的业务需求引起的,通常情况下不需要这样。
| meta | description |
|---|---|
| 返回 | Boolean |
| 定义于 | cocos2d/core/platform/CCObject.js:540 |
参数列表
valueAnystrictModeBoolean If true, Object called destroy() in this frame will also treated as invalid.
示例
var node = new cc.Node();
cc.log(cc.isValid(node)); // true
node.destroy();
cc.log(cc.isValid(node)); // true, still valid in this frame
// after a frame...
cc.log(cc.isValid(node)); // false, destroyed in the end of last frame
deserialize
将 JSON 反序列化为对象实例。
| meta | description |
|---|---|
| 返回 | object |
| 定义于 | cocos2d/core/platform/deserialize-editor.js:715 |
参数列表
dataString | Object the serialized cc.Asset json string or json object.detailsDetails additional loading resultoptionsObject
instantiate
克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。
(Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。)
| meta | description |
|---|---|
| 返回 | Node | Object |
| 定义于 | cocos2d/core/platform/instantiate.js:37 |
参数列表
示例
// instantiate node from prefab
var scene = cc.director.getScene();
var node = cc.instantiate(prefabAsset);
node.parent = scene;
// clone node
var scene = cc.director.getScene();
var node = cc.instantiate(targetNode);
node.parent = scene;
find
Finds a node by hierarchy path, the path is case-sensitive. It will traverse the hierarchy by splitting the path using '/' character. This function will still returns the node even if it is inactive. It is recommended to not use this function every frame instead cache the result at startup.
| meta | description |
|---|---|
| 返回 | Node | Null |
| 定义于 | cocos2d/core/utils/find.js:30 |
参数列表
color
通过该方法来创建一个新的 Color/Color:method 对象。 Alpha 通道是可选的。默认值是 255。
| meta | description |
|---|---|
| 返回 | Color |
| 定义于 | cocos2d/core/value-types/color.ts:885 |
参数列表
示例
-----------------------
// 1. All channels seperately as parameters
var color1 = new cc.Color(255, 255, 255, 255);
// 2. Convert a hex string to a color
var color2 = new cc.Color("#000000");
// 3. An color object as parameter
var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255});
mat4
通过该简便的函数进行创建 cc.Mat4 对象。
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1998 |
参数列表
m00Number Component in column 0, row 0 position (index 0)m01Number Component in column 0, row 1 position (index 1)m02Number Component in column 0, row 2 position (index 2)m03Number Component in column 0, row 3 position (index 3)m10Number Component in column 1, row 0 position (index 4)m11Number Component in column 1, row 1 position (index 5)m12Number Component in column 1, row 2 position (index 6)m13Number Component in column 1, row 3 position (index 7)m20Number Component in column 2, row 0 position (index 8)m21Number Component in column 2, row 1 position (index 9)m22Number Component in column 2, row 2 position (index 10)m23Number Component in column 2, row 3 position (index 11)m30Number Component in column 3, row 0 position (index 12)m31Number Component in column 3, row 1 position (index 13)m32Number Component in column 3, row 2 position (index 14)m33Number Component in column 3, row 3 position (index 15)
quat
通过该简便的函数进行创建 cc.Quat 对象。
| meta | description |
|---|---|
| 返回 | Quat |
| 定义于 | cocos2d/core/value-types/quat.ts:1014 |
参数列表
size
创建一个 cc.Size 对象的帮助函数。
注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。
| meta | description |
|---|---|
| 返回 | Size |
| 定义于 | cocos2d/core/value-types/size.ts:170 |
参数列表
示例
var size1 = cc.size();
var size2 = cc.size(100,100);
var size3 = cc.size(size2);
var size4 = cc.size({width: 100, height: 100});
rect
该方法用来快速创建一个新的矩形。Rect/Rect:method
| meta | description |
|---|---|
| 返回 | Rect |
| 定义于 | cocos2d/core/value-types/rect.ts:433 |
参数列表
示例
var a = new cc.Rect(0 , 0, 10, 0);
clamp
Clamps a value between a minimum float and maximum float value.
| meta | description |
|---|---|
| 返回 | number |
| 定义于 | cocos2d/core/value-types/utils.ts:56 |
参数列表
clamp01
Clamps a value between 0 and 1.
| meta | description |
|---|---|
| 返回 | number |
| 定义于 | cocos2d/core/value-types/utils.ts:69 |
参数列表
valnumber
lerp
| meta | description |
|---|---|
| 返回 | number |
| 定义于 | cocos2d/core/value-types/utils.ts:80 |
参数列表
random
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/utils.ts:109 |
randomRange
Returns a floating-point random number between min (inclusive) and max (exclusive).
| meta | description |
|---|---|
| 返回 | number |
| 定义于 | cocos2d/core/value-types/utils.ts:114 |
参数列表
randomRangeInt
Returns a random integer between min (inclusive) and max (exclusive).
| meta | description |
|---|---|
| 返回 | number |
| 定义于 | cocos2d/core/value-types/utils.ts:126 |
参数列表
pseudoRandom
Linear congruential generator using Hull-Dobell Theorem.
| meta | description |
|---|---|
| 返回 | number |
| 定义于 | cocos2d/core/value-types/utils.ts:138 |
参数列表
seednumber the random seed
pseudoRandomRange
Returns a floating-point pseudo-random number between min (inclusive) and max (exclusive).
| meta | description |
|---|---|
| 返回 | number |
| 定义于 | cocos2d/core/value-types/utils.ts:150 |
参数列表
pseudoRandomRangeInt
Returns a pseudo-random integer between min (inclusive) and max (exclusive).
| meta | description |
|---|---|
| 返回 | number |
| 定义于 | cocos2d/core/value-types/utils.ts:163 |
参数列表
nextPow2
Returns the next power of two for the value
| meta | description |
|---|---|
| 返回 | number |
| 定义于 | cocos2d/core/value-types/utils.ts:176 |
参数列表
valnumber
repeat
Returns float remainder for t / length
| meta | description |
|---|---|
| 返回 | number |
| 定义于 | cocos2d/core/value-types/utils.ts:195 |
参数列表
repeat
Returns time wrapped in ping-pong mode
| meta | description |
|---|---|
| 返回 | number |
| 定义于 | cocos2d/core/value-types/utils.ts:207 |
参数列表
repeat
Returns ratio of a value within a given range
| meta | description |
|---|---|
| 返回 | number |
| 定义于 | cocos2d/core/value-types/utils.ts:221 |
参数列表
sign
Returns -1, 0, +1 depending on sign of x.
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/utils.ts:234 |
参数列表
vnumber
v2
通过该简便的函数进行创建 cc.Vec2 对象。
| meta | description |
|---|---|
| 返回 | Vec2 |
| 定义于 | cocos2d/core/value-types/vec2.ts:1213 |
参数列表
示例
var v1 = cc.v2();
var v2 = cc.v2(0, 0);
var v3 = cc.v2(v2);
var v4 = cc.v2({x: 100, y: 100});
v3
通过该简便的函数进行创建 cc.Vec3 对象。
| meta | description |
|---|---|
| 返回 | Vec3 |
| 定义于 | cocos2d/core/value-types/vec3.ts:1454 |
参数列表
示例
var v1 = cc.v3();
var v2 = cc.v3(0, 0, 0);
var v3 = cc.v3(v2);
var v4 = cc.v3({x: 100, y: 100, z: 0});
get
| meta | description |
|---|---|
| 返回 | Number |
| 定义于 | cocos2d/core/3d/physics/cocos/utils/array-collision-matrix.ts:41 |
参数列表
set
| meta | description |
|---|---|
| 定义于 | cocos2d/core/3d/physics/cocos/utils/array-collision-matrix.ts:57 |
参数列表
reset
| meta | description |
|---|---|
| 定义于 | cocos2d/core/3d/physics/cocos/utils/array-collision-matrix.ts:73 |