Objective C - 通过点击精灵生成字符串,这可能吗?
我将描述这个问题,我的精灵都是字母表中的字母,我想知道当你触摸这些字母形成一个单词时我该如何做到这一点,我可以生成一个该单词的字符串,并通过它与一个字符串进行比较有一个plist。我需要任何可以帮助我的想法,谢谢。
I will describe the problem, I have sprites that are all letters of the alphabet, and I wonder how I can do that when you touch the letters form a word and I can generate a string that word and through it to compare with a string that have a plist. I need any idea that might help me, thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这是可能的。测试触摸的一种方法是使用 CCTouchDispatcher。
概述
从调度程序回调方法注册和取消注册
以实现用于
测试是否触摸 Sprite 的示例代码
Yes, this is possible. One way to test for touches is by using the CCTouchDispatcher.
Overview
Register and unregister from Dispatcher
CallBack Methods To Implement
Example Code For Testing If Touch In Sprite
也许使用 CCMenuItem 会更简单(它也可以从精灵创建),因为它已经是可触摸的。您所要做的就是指定当 CCMenuItem 被触摸时将调用的函数。
看看官方的编程指南:
http://www.cocos2d-iphone.org/wiki/doku .php/prog_guide:lesson_3._menus_and_scenes
Maybe it will be more simple to use CCMenuItem (it can also be created from sprite) because it's already touchable. Everything you have to do is to specify a function will be called, when CCMenuItem is touched.
Take a look at the official programming guide:
http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:lesson_3._menus_and_scenes