ios - How to make SKSpriteNode reappear on the opposite side of its SKScene? -


i have been experimenting spritekit time now, , appreciate “best practice” input regarding movement of skspritenode within skscene’s bounds.

using accelerometer, applying forces on skspritenode's physicsbody property in order move node around screen in marble-like fashion. currently, set physicsbody of scene using self.physicsbody = [skphysicsbody bodywithedgeloopfromrect:self.frame] marble bounces off of scene's edges.

instead of bouncing off of scene's edges, hoping once marble moved beyond scene’s bounds (1) reappear same velocity on opposite side of scene (2). want bounds wrapping occur , in such way when portion of marble has moved outside of scene’s bounds (3), portion have become visible on opposite side of scene (4).

is possible accomplish while using single skspritenode , preserving node’s physicsbody?

thanks in advance!

desired marble movement

nope. need 4 sprite nodes if sprite can leave screen in direction avoid sprite merely "popping" in , out when switching sides. have synchronize positions , velocities choosing 1 of 4 sprites "master" sprite.

the other 3 merely there represent sprite visually along screen edges picking physics contacts (this may tricky because each 1 of nodes can contact, , 4 may make same contact @ once). otoh may not necessary give other 3 physics bodies depending on other bodies there collide with. because "slaves" might collide if master collide too, true if other bodies use same mechanism or collisions never occur near screen borders.

you offset 3 copies +width, +height , +width+height of scene size , recalculate offset every frame based on master sprite position. , have change master sprite position when leaves 1 side of screen. instance when master sprite leaves right side of screen subtract (not set!) width of scene size x position.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -