---
title: "cocos2d中JumpBy的参数详细解释"
author: "grantren"
date: "2013-07-22T23:11:02Z"
tags: ["Objective-C", "cocos2d"]
categories: ["移动开发"]
slug: "cocos2d-jumpby"
draft: false
lastmod: "2013-07-22T23:11:02Z"
id: 1911941
url: "https://grantren.iteye.com/blog/1911941"
---

最近需要使用CCJumpBy实现一个原地跳跃的箭头，在网上查了一下参数，结果多数都是语焉不详，自己写代码测试了下实际参数的意义，这里记录一下。

 

CCJumpBy原型如下：

CCJumpBy::create(ccTime duration, CCPoing pos, float height, int jumps);

 

示例代码：

CCSprite* arrow = \[CCSpritespriteWithSpriteFrameName:@"jumping\_arrow.png"];

arrow.position = CGPointMake(200, 200);

CCJumpBy* jump = \[CCJumpByactionWithDuration:10position:ccp(0, 0) height:100 jumps:2];

 

这里，具体的含义是：

从(200,200)的位置起跳，距离终点的距离是(0,0)，也就是原地起跳，最终目的地也是原地。起跳高度是100，10秒钟完成两次这样的跳跃动作，包括起跳和下落。