如何使用Cocos2D检测iPhone的震动?
我知道如何为 iPhone 摇动,这里已经被问了一百万次,但我似乎找不到任何关于 Cocos2D 加速度计的有用信息。我发现的所有内容都涉及使用视图,我不认为我在 Cocos2D 中使用任何视图,如果我使用的话,我想它们对我来说是隐藏的。我希望能够判断 CCLayer 类中何时发生任何形式的震动?
I know how to do shake for the iPhone has been asked a million times on here, but I can't seem to find anything useful regarding the accelerometer with Cocos2D. Everything i have found involves using views and I don't think i am using any views in Cocos2D, if I am they are hidden from me I think. I want to be able to tell when any sort of shake has occured within a CCLayer class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想通了。在图层类中,您需要放置这些线;
然后在layer类中实现这个函数;
shake_once 只是一个布尔值,用于阻止多次注册一次摇动。
I figured it out. In the layer class you need to put these lines;
Then implement this function in the layer class;
shake_once is just a boolean to stop one shake from being registered more than once.