ios - SpriteKit Physics Joints corrupt for moving scene -


i've created spritekit scene physics bodys. working quite well. i'm scrolling scene around, using apple best practice "camera node".

my scenes node tree that:

scene |- world    |- camera node    |- game nodes physics bodys 

my problem is, during game create new nodes new joints (mostly fixed joints) dynamically. @ point, world node has different position in beginning (eg.: @ start (0,0), during game (1000,500)..) now, anchorpoint fixed joints not @ position want to, it's somewhere in scene.

i assume, coordinate system of scene different coordinate system of physics engine.

for anchor point, use following conversion:

[world.scene convertpoint:node.position fromnode:node.parent]; 

i want set anchorpoint @ position of "node". after moving world node, calculation of anchorpoint not working anymore.

thanks help!

greetz - nekro

update:

code center scene on player

- (void)centeronnode:(sknode*)node {     cgpoint camerapositioninscene = [node.scene convertpoint:node.position fromnode:node.parent];     node.parent.position = cgpointmake(node.parent.position.x - camerapositioninscene.x, node.parent.position.y - camerapositioninscene.y); } 

there 2 requirements using joints spritekit physics:

  1. define joints in world (scene) space.
  2. don't move world.

from question , comments, sounds you've got #1 right: when joint between nodes aren't direct children of scene, need convert coordinates scene space before using them define joint.

however, spritekit physics doesn't handle when try move root coordinate system. so, implementing "camera" moving world causes trouble joints. instead:

  • if can afford target ios 9.0 / os x 10.11 / tvos 9.0 , up, use skcameranode instead of moving world. it's easier, too!

    (if you're wondering whether can support ios 9, check adoption rate statistics, , compare development schedule... if won't shipping awhile, ios 9 might "-1" os version time you're done. remember there's high correlation between enthusiastic customers , adopters.)

  • if you're supporting ios 8 / os x 10.10 still, try adding layer scene: fake camera moving node child of scene , parent of game content.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -