skphysicsbody

IOS 13 Sprite Kit Issues

六眼飞鱼酱① 提交于 2019-12-01 12:08:26
问题 I recently made a game using sprite kit xcode 10.2 which was working fine unless ios 13 update, I tested the game in xcode 11 simulators with ios 13 the fps of the game starts to get reduce to 30-35fps. Also sometimes physics body on sprite nodes is not working properly. sometimes collision is detected on sprite nodes and sometimes it is being detected in middle of the sprite node which was not the case in ios 12 everything was working fine until ios 13 update. 来源: https://stackoverflow.com

SpriteKit move rotated physicsBody with applyImpulse

╄→尐↘猪︶ㄣ 提交于 2019-12-01 11:47:31
I want to move a physicsBody with the applyImpulse method in a direction based on the physicsBody rotation. Foe example, the physicsBody is a square in shape, I call a "move" which will apply an impulse to make it move up vertically. I then call a method to rotate the physicsBody 45 degrees right. If I call the "move" method again, the physicsBody will move diagonally right and up. Can anyone help please? I suggest that you follow Sprite Kit’s coordinate and rotation conventions. Specifically, your sprite image should be facing right at zero degrees (the default value), and a positive value is

SpriteKit iPhone/iPad different resolution, need same physics

删除回忆录丶 提交于 2019-11-30 18:24:13
As I am porting an iPhone app that uses SpriteKit to iPad, I have been able to scale all the screen elements and font sizes using the height ratio of the iPhone 5 to iPad screen. Everything looks proportional, except for the physics since there is more area. So the question is, how do I scale the physics along with the screen using that height ratio? Perhaps changing density or mass of all the nodes? How would I do it, mathematically using the ratio so that it is perfect? You can configure the SKPhysicsWorld object attached to the SKScene . It changes: The gravity property that applies an

Sprite Kit - Apply Impulse to shoot projectile at character

社会主义新天地 提交于 2019-11-30 14:53:53
I am developing a game using Sprite-Kit (Objective-C). It's a game where you control a bird in flight and arrows and other bad projectiles are shot at you from the right/top/bottom sides of the screen. I am using physics instead of an SKAction in order to accomplish this as I want it to seem as life-like as possible. So I know to use applyImpulse on the projectile to shoot it towards the bird, but what I am wondering is how can gaurantee that the projectile will be shot directly at the bird, no matter the y-positioning of the bird and the y-positioning of the projectile prior to applyImpulse?

How to implement a physical effect in SimCity 5, that a building swings when it is being moved?

会有一股神秘感。 提交于 2019-11-30 14:06:22
问题 It is hard to describe in plain text, so I recorded a GIF to demonstrate. https://public.lightpic.info/image/2B1F_582465841.gif I am currently working on a project that requires such effect. Up to now I have finished a similar effect on iOS with SpriteKit, however unfortunately it turns out the result is not pretty satisfying. This is my work: in my project there is an object with an irregular shape, a constant force is applied at somewhere below the gravity center of the object and its

SpriteKit: detect complete node overlap

亡梦爱人 提交于 2019-11-30 13:34:49
问题 I have two SKShapeNodes – one with an edge-based SKPhysicsBody, one volume-based – and I want to detect their intersection without collision. I've got this working fine, with the SKPhysicsContactDelegate contact methods getting called as one passes over another, but my issue is that didEndContact gets called when the edges no longer intersect, even when one body is completely contained within the other. What's the best way to determine true contact or overlap, not just edge intersection? I've

SpriteKit: How to create Basic Physics Joints

倾然丶 夕夏残阳落幕 提交于 2019-11-30 12:56:20
I am trying to create simple Joints between two SKPhysicsBodies. But, they are acting weirdly. I am well aware of the fact the anchor points should be on scene coordinate. Please have a look at the Source code attached. For Example this is how a fixed Joint results after attaching a small square on a rectangle. -(void)createFixedJointOnScene:(SKScene*)scene { //Adding Rectangle SKSpriteNode* backBone = [[SKSpriteNode alloc] initWithColor:[UIColor whiteColor] size:CGSizeMake(20, 200)]; backBone.position = CGPointMake(CGRectGetWidth(self.frame)/2.0, CGRectGetHeight(self.frame)/2.0); backBone

How to implement a physical effect in SimCity 5, that a building swings when it is being moved?

淺唱寂寞╮ 提交于 2019-11-30 09:34:08
It is hard to describe in plain text, so I recorded a GIF to demonstrate. https://public.lightpic.info/image/2B1F_582465841.gif I am currently working on a project that requires such effect. Up to now I have finished a similar effect on iOS with SpriteKit, however unfortunately it turns out the result is not pretty satisfying. This is my work: in my project there is an object with an irregular shape, a constant force is applied at somewhere below the gravity center of the object and its direction is downward. I have made it a rule that the object's coordinate cannot be changed by the force, so

SpriteKit: detect complete node overlap

懵懂的女人 提交于 2019-11-30 07:42:07
I have two SKShapeNodes – one with an edge-based SKPhysicsBody, one volume-based – and I want to detect their intersection without collision. I've got this working fine, with the SKPhysicsContactDelegate contact methods getting called as one passes over another, but my issue is that didEndContact gets called when the edges no longer intersect, even when one body is completely contained within the other. What's the best way to determine true contact or overlap, not just edge intersection? I've tried usesPreciseCollisionDetection , to no avail. CGPoint locObj1 = [sprite1 locationInNode:self];

Can't understand how collision bit mask works

て烟熏妆下的殇ゞ 提交于 2019-11-30 07:25:50
问题 I am trying to use collision bit masks and contact test bit masks in Swift, I want two objects not to collide together, so I am doing : firstNode.physicsBody?.collisionBitMask = 0b01 secondNode?.collisionBitMask = 0b10 Since SpriteKit does an AND operation on those two numbers, shouldn't the result be 00 since 10 & 01 = 00 ? So why are collisions happening anyway ? Thank you. 回答1: That is not how collision handling works. When two bodies are in intersection, physics engine performs logical