- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我在 Xcode 中创建了一个粒子发射器,它有很长的轨迹。当我将它移动到粒子发生器内部时,它会沿着我的鼠标路径留下一条轨迹。
关于我的目标的一些背景信息:在我的 spriteKit 游戏中,用户在屏幕上拖动他们的手指来射击移动的物体。我正在尝试创建一个“子弹时间”效果,当当前手指位置接触到对象时,对象会减慢并突出显示。当手指停止移动或弹药用完时,将触发 touchesEnded 方法射击所有突出显示的对象。目前,我使用 SKShapeNode 和 CGPath 将它们行进的路径显示为在屏幕上绘制的一条线,但我希望使用发射器轨迹突出显示轨迹。
在 touches begind 方法中,我创建了一个圆圈 SpriteNode,它会在手指移动到的任何地方移动(物理碰撞附加到圆圈而不是路径)。我已将粒子轨迹发射器连接到此圆圈,当我在屏幕上移动它时它会随着圆圈一起移动,但不会留下轨迹。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInNode:self];
pathToDraw = CGPathCreateMutable();
startPoint = touchLocation;
CGPathMoveToPoint(pathToDraw, NULL, touchLocation.x, touchLocation.y);
lineNode = [SKShapeNode node];
lineNode.path = pathToDraw;
lineNode.lineWidth = 2;
lineNode.zPosition = 110;
lineNode.strokeColor = [SKColor whiteColor];
[self addChild:lineNode];
circle = [SKSpriteNode spriteNodeWithTexture:[animationsAtlas textureNamed:@"anim_countdown_9"]];
circle.name = @"circle";
circle.scale = 0.3;
circle.alpha = 0.5;
circle.zPosition = 110;
circle.position = touchLocation;
circle.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:20];
circle.physicsBody.categoryBitMask = weaponCategory;
circle.physicsBody.dynamic = NO;
circle.physicsBody.contactTestBitMask = billyCategory;
circle.physicsBody.collisionBitMask = 0;
[self addChild:circle];
pathEmitter = [SKEmitterNode skt_emitterNamed:@"FollowPath"];
//pathEmitter.position = circle.position;
//pathEmitter.targetNode = self;
//pathEmitter.scale = 0.2;
//pathEmitter.zPosition = 60;
[circle addChild:pathEmitter];
}
在 touchesMoved 方法中,我将圆相应地移动到新位置
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInNode:self];
circle.position = currentPoint;
SKAction *wtf = [SKAction followPath:pathToDraw asOffset:NO orientToPath:YES duration:0.1];
//pathEmitter.position = currentPoint;
//[pathEmitter runAction:wtf];
//pathEmitter.particleAction = wtf;
pathEmitter.particleAction = [SKAction moveTo:currentPoint duration:1.0];
CGPathAddLineToPoint(pathToDraw, NULL, currentPoint.x, currentPoint.y);
lineNode.path = pathToDraw;
我试过像这篇文章一样设置 pathEmitter.targetNode = self; Making a particle follow a path in spriteKit建议,但发射器根本不会出现。
如果我将 particleAction 设置为 followPath,它也不会留下痕迹。
在我的代码中你可以看到我已经注释掉了一些行,基本上我已经尝试了我能想到的 targetNode 和 particleAction 的所有组合。
关于如何让发射器在我的手指路径上留下痕迹的任何建议?
谢谢
最佳答案
实际上是 pathEmitter.targetNode = self;是一种让你有一个粒子在你的物体移动时留下痕迹的方法,我看不出它对你不起作用的任何原因因为我很久以前就一直在使用这种方法,检查一下你的位置专门用于方法 touchesMoved
关于ios - 让粒子发射器轨迹跟随 spriteKit 中的手指路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22645904/
我有一系列 gps 值,每个值包含:timestamp, latitude, longitude, n_sats, gps_speed, gps_direction, ... ( NMEA data
我正在尝试绘制两点之间的轨迹路径。我只知道有问题的两点和它们之间的距离。我希望能够计算的是到达终点所需的速度和角度。 我还希望能够将一些重力和风因素考虑在内,这样路径/轨迹就不那么“完美”了。它用于电
有没有人对使用顶点缓冲区/4f 颜色缓冲区绘制粒子在 opengl 中对来自喷气发动机(带有加力燃烧室)的粒子流进行编码的近似值有任何指导? 我认为这个问题有两个方面: 作为温度和与燃烧的气体类型相关
问题 我正在迁移多个 ggplot/ggvis plotly 到 plotly在 shiny应用。我遇到了一个关于跟踪链接的问题。我希望能够通过 group 显示/隐藏痕迹在图例上,在相关数据框之间共
我想为玩具车在没有障碍物的平面 (2d) 上规划一条路线。玩具车应该从点 (p1x,p1y) 移动到 (p2x,p2y)(又名狄利克雷边界条件)。此外,玩具车在起点的速度是(v1x,v1y),终点处要
我正在开发一个路径/ map 应用程序,该应用程序在一个区域中绘制了自定义路径,并将帮助用户在“森林”区域的一些路径周围导航。 目前,我正在使用 MKMapView 来获取用户数据/位置,并从 KML
我目前正在尝试根据从 iPhone 视频中拍摄的一系列图像重建坠落物体(例如球或石头)的 3D 轨迹。 我应该从哪里开始寻找?我知道我必须校准相机(我想我会使用 Jean-Yves Bouguet 的
我正在尝试使用 matplotlib 在 map 上绘制 CSV 文件中的线条和标记。 数据: AL99,2017080912,SHIP,0,17.1,-55.6,25,0 AL99,20170809
我正在尝试仅使用广播源来重建篮球的 3D 轨迹。 为此,我必须计算单应矩阵,因此在每一帧中,我都成功地跟踪了球,以及它们在“现实世界”中的位置已知的 6 个点(4 个在球场上,2 个在篮板上)为在图片
如果我有一个像这样的动画圈 example , 有没有一种方法可以在 Canvas 上留下 1px 纯白色的永久痕迹? 我试过动态构建路径,但无法让它工作。 提前致谢,如有任何帮助,我们将不胜感激 最
正在工作,即将发布,没有真正的更新,[6.3.2] 突然出现此错误。 花了一天时间在 OAuthSwift V0.3.4、0.3.5、0.3.6 之间切换,同样的错误发生了。还有一次(但非常罕见),我
我正在尝试使用 matlab/octave 为这个螺旋制作动画我希望它向上或向下螺旋 t = 0:0.1:10*pi; r = linspace (0, 1, numel (t)); z = lins
我有一个有点难的算法问题,我从很多搜索中找不到任何合适的算法,所以我希望 stackoverflow 上的人可能知道答案。 我有一组车辆在 2D 空间中移动时的 x,y 坐标,坐标记录在时间段内的“决
在服务器(MySQL 或 Oracle 或任何文件)上存储 GPS 坐标(航迹)的最佳方式是什么?例如,GoogleMaps 是如何实现的?我想保存和比较相同部分的轨道。 附言我有所有必要的数据。 最
The link to download the GPS traces on OSM is quite easy to get. 但是,里面的每个文件都 super 大。而且也没有地理位置分类。所以我
这个问题与地理空间信息系统的知识有些重叠,但我认为它属于这里而不是 GIS.StackExchange 有很多应用程序处理具有非常相似对象的 GPS 数据,其中大多数由 GPX standard 定义
我正在使用此处找到的 locu-node node.js 库:https://github.com/Locu-Unofficial/locu-node ,这是 Locu 服务的 API 客户端。在提供
我正在尝试将一个元素从位置 A 动画到位置 B,但我不希望它在每个点之间线性移动,我希望有一种“抛物线”轨迹。 我可以使用 jQuery.animate() 吗? 或者我应该使用 setInterva
总结:如何避免不同线程的不同工作负载导致的性能损失? (内核在每个线程上都有一个 while 循环) 问题:我想在许多不同的初始条件下使用 Runge-Kutta 求解粒子轨迹(由二阶微分方程描述)。
我正在创建一个应用程序,其中包含一些变量的区域数据。该应用程序允许您通过 selectInput 选择用户想要可视化的区域。出于比较/信息目的,我希望用户在 plot_ly 中可视化所选区域以及全国平
我是一名优秀的程序员,十分优秀!