简体   繁体   English

如何在iOS SpriteKit中添加滚动背景效果。

[英]How to add Scrolling Background Effect in iOS SpriteKit.

I want to add scrolling background effect to my scene. 我想在场景中添加滚动背景效果。 For example when user gesture is to right side or left side, then background should scroll horizontally and if upside or to downside then background should scroll vertically to add effect as a character is really moving. 例如,当用户手势位于右侧或左侧时,背景应水平滚动;如果向上或向下,则背景应垂直滚动以增加角色的真实移动效果。

Thanks in advance. 提前致谢。

Look at the Adventure game code explained by Apple for SpriteKit. 查看Apple为SpriteKit解释的Adventure游戏代码。 The section that has to do with your question is "Moving the Camera". 与您的问题有关的部分是“移动相机”。 Essentially it is adding the nodes to a "World" node and then moving the "World" node around based on user input or character movement. 本质上,它是将节点添加到“世界”节点,然后根据用户输入或角色移动来移动“世界”节点。

https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/CodeExplainedAdventure/AdventureArchitecture/AdventureArchitecture.html#//apple_ref/doc/uid/TP40013140 https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/CodeExplainedAdventure/AdventureArchitecture/AdventureArchitecture.html#//apple_ref/doc/uid/TP40013140

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM