Connecting Physics Bodies

  The kinds of joints you can create in Sprite Kit.

  

  

  You add or remove joints using the physics world. When you create a joint, the points that connect the joint are always specified in the scene’s coordinate system. This may require you to first convert from node coordinates to scene coordinates before creating a joint.

To use a physics joint in your game, follow these steps:

  1. Create two physics bodies.
  2. Attach the physics bodies to a pair of SKNode objects in the scene.
  3. Create a joint object using one of the subclasses listed in Table 8-3.
  4. If necessary, configure the joint object’s properties to define how the joint should operate.
  5. Retrieve the scene’s SKPhysicsWorld object.
  6. Call the physics world’s addJoint: method.

Searching for Physics Bodies

  Sometimes, it is necessary to find physics bodies in the scene. For example, you might need to:

  • Discover whether a physics body is located in a region of the scene.
  • Detect when a physics body (such as the one controlled by the player) crosses a particular line.
  • Trace the line of sight between two physics bodies, to see whether another physics body, such as a wall, is interposed between the two objects.

  In some cases, you can implement these interactions using the collisions and contacts system. For example, to discover when a physics body enters a region, you could create a physics body and attach it to an invisible node in the scene. Then, configure the physics body’s collision mask so that it never collides with anything, and its contact mask to detect the physics bodies you are interested in. Your contact delegate is called when the desired interactions occur.

  You can use physicalsworld's [bodyAlongRayStart:end:] to get the body between start & end.

  And you can also use bodyAtPoint: and bodyInRect: to get bodies at point or in rect.

Most Physics Properties Are Dynamic, so Adapt Them at Runtime

  As an object moves throughout the scene, you adjust its linear and rotational damping based on the medium it is in. For example, when the object moves into water, you update the properties to match.

Connecting Physics Bodies的更多相关文章

  1. Physicals

    [Physicals] The physics simulation in Sprite Kit is performed by adding physics bodies to scenes. [T ...

  2. Advanced Scene Processing

    [How a Scene Processes Frames of Animation] In the traditional view system, the contents of a view a ...

  3. Working with Other Node Types

    [Working with Other Node Types] [Shape Nodes Draw Path-Based Shapes] The SKShapeNode class draws a s ...

  4. Sprite Kit教程:初学者

    作者:Ray Wenderlich 原文出处:点击打开链接 http://www.raywenderlich.com/42699/spritekit-tutorial-for-beginners 转自 ...

  5. cocos2d-x3.0 解释具体的新的物理引擎setCategoryBitmask()、setContactTestBitmask()、setCollisionBitmask()

    转载请注明出处:游戏开发实验室http://blog.csdn.net/u010019717/article/details/32942641 我在编写游戏的时候遇到了这个问题.  物理引擎其它的内容 ...

  6. UE4物理笔记

    基本 物理资源随骨骼创建,可添加到骨骼网格上. 物理材质可添加到材质或组件或物理资源上. 通过配置PrimitiveComponent组件的Collision Presets值,可实现自定义的碰撞忽略 ...

  7. Cocos2d-x 3.0中 物理碰撞检測中onContactBegin回调函数不响应问题

    好吧,事实上这篇也是暂时冒出来的,近期朋友要做个物理游戏,曾经做物理还是用box2d,呃.确实要花些功夫才干搞懂当中的精髓,可是听讲这套引擎又一次封装了一次.要easy非常多,所以就简单尝试了一下,感 ...

  8. SpriteKit-(SKNode)

    1.初始化 + (instancetype)node; + (nullable instancetype)nodeWithFileNamed:(NSString*)filename; 2.返回边界边框 ...

  9. [Unity Physics] Physics - Raycast

    Class Variables类变量 gravity The gravity applied to all rigid bodies in the scene.场景中应用到所有刚性物体的重力. min ...

随机推荐

  1. open_binary_frm

    参数uchar* head 是已经分配好内存的64个字节的地址 http://mysql.taobao.org/monthly/2015/08/07/ /** *先从.frm文件读取64字节 *第28 ...

  2. laravel中的$request对象构造及请求生命周期

    laravel应用程序中index.php是所有请求的入口.当用户提交一个form或者访问一个网页时,首先由kernel捕捉到该session PHP运行环境下的用户数据, 生成一个request对象 ...

  3. Spring 实践 -拾遗

    Spring 实践 标签: Java与设计模式 Junit集成 前面多次用到@RunWith与@ContextConfiguration,在测试类添加这两个注解,程序就会自动加载Spring配置并初始 ...

  4. POJ 3468 (线段树 区间增减) A Simple Problem with Integers

    这题WA了好久,一直以为是lld和I64d的问题,后来发现是自己的pushdown函数写错了,说到底还是因为自己对线段树理解得不好. 因为是懒惰标记,所以只有在区间分开的时候才会将标记往下传递.更新和 ...

  5. HDU 5264 pog loves szh I (字符串,水)

    题意:设有两个串A和B,现将B反转,再用插入的形式合成一个串.如:A:abc   B:efg:反转B先,变gfe:作插入,agbfce.现在给出一个串,要求还原出A和B. 思路:扫一遍O(n),串A在 ...

  6. 【C#学习笔记】浏览目录得到路径

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  7. mysql,多对多的hibernate操作对应的jdbc操作

    在hibernate中oo思想操作数据库,很方便,但是需要了解一下底层的jdbcsql是怎么写的,复习 多对多的表关系,取出,id为1的学生 订阅了哪些课程? mysql> select c_n ...

  8. jQuery autoComplete 样式

    前提:使用了jQuery-ui 官网:http://jqueryui.com/autocomplete/ /*** autocomplete ***/ .ui-widget-content { bac ...

  9. postgresql编译安装与调试(二)

    接前文postgresql编译安装与调试(一),继续说说postgresql的编译安装与调试. 上一篇已经详细说明了如何在Linux系统上编译安装postgresql,这次我们在此基础上简单讲讲如何在 ...

  10. [再寄小读者之数学篇](2014-11-24 Abel 定理)

    设幂级数 $\dps{g(x)=\sum_{n=0}^\infty a_nx^n}$ 在 $|x|<1$ 内收敛, 且 $\dps{\sum_{n=0}^\infty a_n=s}$ 收敛. 则 ...