logo
down
shadow

Spritekit node jitters while moving.... why?


Spritekit node jitters while moving.... why?

By : Senzo Pardon Mbuyane
Date : November 21 2020, 07:31 AM
wish help you to fix your issue This is happening because the physics bodies are colliding. By default, an SKPhysicsBody has a restitution of 0.2, making it a little bouncy. Setting enemy.physicsBody.restitution = 0 and doing the same for the physics body your enemy is colliding with should resolve the jitter you're seeing.
code :


Share : facebook icon twitter icon
Node not moving once Physics added to scene: swift, SpriteKit

Node not moving once Physics added to scene: swift, SpriteKit


By : Salman Hossain
Date : March 29 2020, 07:55 AM
wish helps you every time I add the following code: , This line is causing the problem:
code :
ball.physicsBody = SKPhysicsBody(circleOfRadius: size.height / 2)
ball.physicsBody = SKPhysicsBody(circleOfRadius: ball.size.height / 2)
Node moving from Point to Point by touch in SpriteKit Sene

Node moving from Point to Point by touch in SpriteKit Sene


By : Soulgarden
Date : March 29 2020, 07:55 AM
this will help I have a SKNode and I Want to move this node from point (10,10) TO (10,100) by touch .. (and to make this node moving between this two points only )not on the all scene like i have right now in the touch moved method Then .Can I Create a path for my node between these points,If I Can What You Suggest Me To Use . , you can. You have to create a path, like this:
code :
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 0, 0);
CGPathAddLineToPoint(path, NULL, 100, 0);
CGPathAddLineToPoint(path, NULL, 100, 100);
SKAction *followline = [SKAction followPath:path asOffset:YES orientToPath:NO duration:3.0];
[_Player runAction:followline];
Spritekit collision detection. Node moving so fast a collision occurs without any visual touching

Spritekit collision detection. Node moving so fast a collision occurs without any visual touching


By : siva
Date : March 29 2020, 07:55 AM
hop of those help? Since we nailed down the issue, I am going to post it as an answer:
What is happening is during your update phase, you are removing all of your nodes that are involved with the collision, so you will never see them touching.
code :
var removeNodes = [SKNode]()
...

func update(currentTime: CFTimeInterval)
{
   if(removeNodes.count > 0)
   {
     for node in removeNodes
     {
       node.removeFromParent()
     }
   }
   removeNodes.removeAll()
}
... normal update code




...at some point after collision
//node A needs to be removed
removeNodes.append(nodeA)
Swift - Increase speed of a moving Node using SpriteKit

Swift - Increase speed of a moving Node using SpriteKit


By : Martynas Podenas
Date : March 29 2020, 07:55 AM
should help you out Ok, here you go! The ball CONSTANTLY gets faster, no matter what!!! Adjust amount to determine how much the ball gains speed each frame.
code :
class GameScene: SKScene, SKPhysicsContactDelegate {

  let ball = SKShapeNode(circleOfRadius: 20)
  var initialDY = CGFloat(0)
  var initialDX = CGFloat(0)



  override func didMove(to view: SKView) {
    self.physicsBody = SKPhysicsBody(edgeLoopFrom: frame)
    self.physicsWorld.gravity = CGVector.zero

    // Configure ball pb:
    let pb = SKPhysicsBody(circleOfRadius: 20)
    ball.physicsBody = pb
    addChild(ball)

    pb.applyImpulse(CGVector(dx: 10, dy: 10))
  }

  override func update(_ currentTime: TimeInterval) {
    initialDX = abs(ball.physicsBody!.velocity.dx)
    initialDY = abs(ball.physicsBody!.velocity.dy)
  }

  override func didSimulatePhysics() {
    guard let pb = ball.physicsBody else { fatalError() }

    // decrease this to adjust the amount of speed gained each frame :)
    let amount = CGFloat(5)

    // When bouncing off a wall, speed decreases... this corrects that to _increase speed_ off bounces.
    if abs(pb.velocity.dx) < abs(initialDX) {
      if      pb.velocity.dx < 0 { pb.velocity.dx = -initialDX - amount }
      else if pb.velocity.dx > 0 { pb.velocity.dx =  initialDX + amount }
    }

    if abs(pb.velocity.dy) < abs(initialDY) {
      if      pb.velocity.dy < 0 { pb.velocity.dy = -initialDY - amount }
      else if pb.velocity.dy > 0 { pb.velocity.dy =  initialDY + amount }
    }
  }
}
SpriteKit How to detect if node is moving or not

SpriteKit How to detect if node is moving or not


By : Homan Sharifian
Date : March 29 2020, 07:55 AM
this will help Since you are moving the object using the physics engine, all you have to do is check the velocity.
code :
if let v = aCuesMe[someIndex].physicsBody?.velocity {
    if v == CGVector(dx: 0, dy: 0) {
        // Object has 0 velocity and is not moving
    }
}
Related Posts Related Posts :
  • Unclear about releasing CFDictionaryRef
  • CordovaError: Promise rejected with non-error: Error code 65
  • How to append NSMutable strings into a UILabel
  • CustomCell label value does not change
  • Display ad in iAd Bannerview iAd Network
  • Warning: "Could not get traitsetID for iPhone11,6" (Assets.xcassets)
  • Changing root view controller after iOS app has loaded.
  • SocketRocket and iOS certificate pinning
  • Draggable UIButton Snap To a Circle Path
  • Running FireBase in the background
  • resizing UIPopoverController to fit UITableController
  • UICollectionView Exception Crash
  • targeting iOS5 - will it work on iOS6 also?
  • FBLoginView get email
  • Scale UIImages height to UIImageView height
  • Creating a custom progress indicator in ios
  • NSRunLoop API difference
  • Is it possible to inject custom settings into my iOS application "Notifications" settings dialog?
  • UIAlertview not accepting string as message
  • Axis change of stackView giving layout error
  • How to use AVAssetResourceLoader?
  • How to write block definition using properties?
  • iOS connect/reconnect to Bluetooth device when using external-accessory and MFi
  • Saving XMPP Multi User chat messages through XMPP MessageArchiving in iOS
  • Deciding iOS version: pros and cons
  • iOS: Resigned app cannot access keychain through security API
  • How can I set To and Subject fields in an E-Mail being sent by UIDocumentInteractionController?
  • Updating uilabel in view controller underneath another
  • Maximum time Intervel for NSTimer
  • Delete Core Data Entry from Table View Controller
  • How to unload UIViewcontroller from memory?
  • Compressing UIImage as Far as Possible?
  • Optimizing workflow to update internally owned cocoapods dependencies?
  • Formatting an NSDate with Abbreviated Month/Day Names
  • I'm creating a quiz game with 4 answers and I want to add score
  • Tap Gesture to Hide Navigation Bar, Tab Bar, and Status Bar
  • FBSessionStateClosedLoginFailed when I am logged in through Settings
  • CGRect positioning according to center point
  • iOS: Update table view datasource with animations without core data
  • iOS : Where to start for AliPay integration?
  • Routing App Coverage File missing but not needed?
  • Drawing on a zoomable view
  • Append NSStrings and NSNumber to NSMutableArrays and make NSMutable dictionary
  • Terminating app due to uncaught exception 'NSRangeException' when calling dequeueReusableCellWithReuseIdentifier:forInde
  • Collision without physics (Cocos2D + Box2D iOS)
  • Creating a percentage based iOS layout
  • Update tableView row from AppDelegate Swift 4
  • Assigning return value of a class method to a variable error
  • how to display circular progress in delphi ios apps?
  • I can't figure how to fix this Expected identifier or '('
  • How to Test APIs in Swift 4?
  • Link error /Build/Products/Debug-iphonesimulator file not found
  • working with a very large JSON object in iOS
  • Turn off part of the iPhone Screen
  • Phonegap 3.0 app with facebook login using xCode
  • How to add interstitial admob ads to my ios project
  • adding tapku calendar to ios app
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org