SpriteKit 笔记整理(不全)

因为一直都想制作游戏~~最近这段时间都在研究者spritekit这个框架..虽然技术还不是很稳定..已经在着手开始制作者一个游戏了 大笑
图片靠我一个朋友帮我画画~~平常除了上班..做完开发以后就开始研究spritekit...现在游戏框架都整理的差不多了~~就先把之前一直研究记录的笔记放上来更新下~~~内容可能不全.还有着一些是从树上copy过来的~~~
还可能存在重复~~~

SKPhysicsBody类定义了一些物理属性
mass属性决定力是如何影响主体,以及当主体参与碰撞时它又多大的动量.
friction属性决定了主体表面的粗糙度,它被用来计算一个主体沿其他主体表面移动时的摩擦.
linearDamping和angularDamping属性是用来计算主体在世界中移动时的摩擦,例如,他可能用于空气或水的摩擦.
restitution属性决定主体在碰撞过程中保持多少能力,反弹力
dynamic属性决定该主体是否由物理子系统模拟
affectedByGravity属性决定模拟是否对主体产生重力.
allowsRotation属性决定力是否对主体传递角速度

SKPhysicsWorld对象两个重要的特性:
gravity属性对模拟中基于体积的主体试驾加速度.静态(dynamic = false)和affectedByGravity属性设置为false的物理体则不受影响
speed属性决定了模拟的运行速率

把静态对象进行更改为属性有dynamic动画属性必须设置物理世界的重力,不然默认Y轴的重力为-9.80000
物理世界设置必须在运行方法里增加self.physicswold.contactDelegate = self把代理设置好,不设置就也不会进入物理碰撞方法
两者静态图片不能进行物理碰撞
categortBitMask为碰撞标识(即碰撞名称)
contactTestBitMask碰撞测试(定位需要碰撞的那家伙的BitMask标识符)
collisionBitMask碰撞产生效果的表示,如果不产生效果就不设置

categoryBitMask 它标记了物体属于那一类物体  类掩码
collisionBitMask 它标记了哪些物体可以与其发生碰撞 允许谁与我碰撞
contactTestBitMask 碰撞了会发送通知给delegate
它标记了哪些物体会和其发生碰撞后产生一些影响
判断其他物体是否跟自己发生碰撞,要根据自己的collisionBitMask的值与对方物体的categoryBitMask进行逻辑与运算,得到的结果不为0,既发生碰撞
判断碰撞的两个物体是否发生影响时,假设为A和B,首先是A的categoryBitMask与B的contactTestBitMask进行逻辑与运算,B也做同样的运算,当两者的结果都不为0时,两者即可在碰撞的时候互相影响

SKPhysicsBody
circaleOfRadius
这个属性针对是有动画效果的.可以与其他body进行碰撞

edge loop body
这个edge loop body针对的为静态的物理体(屏幕)

rectangleOfSize 
针对例如矩形

polygonFromPath 参数为CGPathCreateMutable()
(多边形)


friction: This sets how “slippery” an object is. Values can range from 0.0 (thebody slides smoothly along surfaces like an ice cube) to 1.0 (the body is quicklystopped while sliding along surfaces). The default value is 0.2.

dynamic: Sometimes you want to use physics bodies for collision detection, butmove the node yourself with manual movement or actions. If this is what youwant, simply set dynamic tofalse, and the physics engine will ignore all forcesand impulses on the physics body and let you move the node yourself.

usesPreciseCollisionDetection: By default, Sprite Kit does not perform precisecollision detection, because it’s faster to avoid doing this unless absolutelynecessary. However, this has a side effect in that if an object is moving veryquickly (like a bullet), it might pass through another object. If this ever occurs,you should try turning this flag on to enable more accurate collision detection.

allowsRotation: Sometimes you might have a sprite that you want the physicsengine to simulate, but never rotate. If this is the case, simply set this flag tofalse.

linearDampingandangularDamping: These values affect how much the linearvelocity (translation) or angular velocity (rotation) decreases over time. Valuescan range from 0.0 (the speed never decreases) to 1.0 (the speed decreasesimmediately). The default value is 0.1.

affectedByGravity: All objects default as affected by gravity, but you can setthis off for a body simply by setting this tofalse.

resting: The physics engine has an optimization where objects that haven’tmoved in a while are flagged as ‘resting’ so the physics engine does not have toperform calculations on them any more. If you ever need to “wake up” a restingobject manually, simply set this flag tofalse.

mass and area: These are automatically calculated for you based on the shapeand density of the physics body. However, if you ever need to manually overridethese values, they are here for you.

node: The physics body has a handy pointer back to the SKNodeit belongs to.


categoryBitMask , collisionBitMask , contactBitMask , and joints : You willlearn all about these in Chapter 9, “Intermediate Physics” and Chapter 10,“Advanced Physics.”
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值