简体   繁体   English

在SKSpriteNode周围绘制圆圈并拖动触摸

[英]Draw circle and drag touch around SKSpriteNode

I am making a Sprite Kit game where the player (basically a stickman) has a running animation and a parallax scrolling background. 我正在制作一个Sprite Kit游戏,其中的玩家(基本上是火柴人)具有正在运行的动画和视差滚动背景。

Now I have enemies that come near my player. 现在我有敌人靠近我的玩家。 To destroy these enemies sometimes I have to touch the enemies node to launch a rocket or attack them with an attack button or just jump over them. 为了消灭这些敌人,有时我必须触摸敌人节点以发射火箭或使用攻击按钮攻击他们,或者跳过它们。

Everything is working fine, but I want to add some extra moves to destroy them. 一切工作正常,但我想添加一些其他措施来销毁它们。 I want some enemies that you can just destroy if you have drawn a whole circle around them. 我想要一些敌人,只要在他们周围画上一个圆就可以消灭它们。 So imagine they come and you make a circle and then my player launch a laser or something. 想象一下他们来了,你绕了一个圈,然后我的播放器发射了激光或类似的东西。 The problem is I have no idea where to start. 问题是我不知道从哪里开始。

I haven't found anything on the internet. 我没有在网上找到任何东西。 If it's too complicated or almost impossible how about touching my player node and dragging to the enemy? 如果太复杂或几乎不可能,那么触摸我的玩家节点并拖动到敌人那里怎么办?

EDIT: I think I have to create a custom GestureRecognizer that recognizes if a circle is drawn around a sprite and then runs the code. 编辑:我想我必须创建一个自定义的GestureRecognizer,它可以识别是否在精灵周围绘制了一个圆圈,然后运行了代码。 I don't know how this works ? 我不知道这是怎么回事?

Yes, it's too complex. 是的,它太复杂了。 Not just from a coding point of view, but also from that of the player's experience. 不仅从编码的角度来看,而且从玩家的经验来看。

Anything that requires complex gestures over a large amount of glass is annoying for the player because they're never going to have the same experience. 任何需要在大量玻璃上进行复杂手势的操作,对于玩家来说都是令人讨厌的,因为它们永远不会有相同的体验。 Their finger's moisture and oil content always changes, as does the ambient temperature and cleanliness of their screen. 他们的手指的水分和油含量总是会变化,环境温度和屏幕清洁度也会变化。

So big gestures required to be performed quickly (a gaming input like this) will sometimes be fun and smooth, and other times degrade as an experience based on the nature of the above properties. 因此,需要快速执行的大手势(例如这样的游戏输入)有时会变得有趣且流畅,而其他时间则基于上述属性的性质而降低为一种体验。

Best to avoid them for a game's best possible experience. 最好避免使用它们,以获得游戏的最佳体验。

If you must do it, there's two ways to research how. 如果必须这样做,有两种研究方法的方法。

  1. Seek out "custom gesture" creation and utilisation through documentation and google, etc. 通过文档和Google等寻求“自定义手势”的创建和使用。

  2. Think about using some kind of array to store all the points where the player's finger moves through during that circle gesture and attempt to discern if an enemy is within that space and then act accordingly. 考虑使用某种数组来存储玩家在圆圈手势过程中手指穿过的所有点,并尝试辨别敌人是否在该空间内,然后采取相应的行动。

--- probably other ways, too. ---也可能是其他方式。 But these jump to mind. 但是这些让我想起了。

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

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