- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用以下代码在我的 sprite 套件场景中绘制线条,但没有显示任何内容。但是节点数增加了。任何人都可以看到可能是什么问题。我一直在和这段代码作斗争
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch* touch = [touches anyObject];
CGPoint positionInScene = [touch locationInNode:self];
pathToDraw = CGPathCreateMutable();
CGPathMoveToPoint(pathToDraw, NULL, positionInScene.x, positionInScene.y);
lineNode = [SKShapeNode node];
lineNode.path = pathToDraw;
lineNode.strokeColor = [SKColor redColor];
//lineNode.lineWidth = 2;
[self addChild:lineNode];
}
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch* touch = [touches anyObject];
CGPoint positionInScene = [touch locationInNode:self];
CGPathAddLineToPoint(pathToDraw, NULL, positionInScene.x, positionInScene.y);
lineNode.path = pathToDraw;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
// lineNode.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:pathToDraw];
// lineNode.physicsBody.dynamic = NO;
// lineNode.physicsBody.categoryBitMask = lines;
// lineNode.physicsBody.contactTestBitMask = 0;
// lineNode.physicsBody.collisionBitMask = blueParticles | redParticles| yellowParticles;
CGPathRelease(pathToDraw);
}
编辑------ 删除背景节点后代码正常工作..如何设置我的背景节点以便我可以超越?谢谢
SKSpriteNode *background;
if(screenHeight == 480){
background = [SKSpriteNode spriteNodeWithImageNamed:@"iPhone4BG.png"];
}
if(screenHeight == 568){
background = [SKSpriteNode spriteNodeWithImageNamed:@"iPhone5BG.png"];
}
if(screenHeight == 667){
background = [SKSpriteNode spriteNodeWithImageNamed:@"iPhone6BG.png"];
}
if(screenHeight == 736){
background = [SKSpriteNode spriteNodeWithImageNamed:@"iPhone6PlusBG.png"];
}
background.position = CGPointMake(screenWidth/2, screenHeight/2);
background.size = CGSizeMake(screenWidth, screenHeight);
// [self addChild:background];
最佳答案
注意 核心问题是模拟器没有呈现未闭合的路径。在设备上不存在该问题。还涉及原始海报未提及且未在代码中表示的背景元素。这个答案将解决模拟器上的问题。
要解决您的问题,请按如下方式修改您的代码:
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch* touch = [touches anyObject];
CGPoint positionInScene = [touch locationInNode:self];
CGPathAddLineToPoint(pathToDraw, NULL, positionInScene.x, positionInScene.y);
// add this line to fix your issue
CGPathMoveToPoint(pathToDraw, NULL, positionInScene.x, positionInScene.y);
lineNode.path = pathToDraw;
}
核心问题是去渲染路径的时候,没有完整的路径。您当前的方法是不断修改每个 touchMove 的路径。
关闭子路径的方式是:
CGPathCloseSubpath(pathToDraw);
但是我选择在每次向路径添加段时只使用CGPathMoveToPoint
。
来自 CGPathMoveToPoint
的 CGPath 引用:
此函数结束已经在进行中的子路径(如果有的话)并开始一个新的子路径,在可选转换之后将起点和当前点初始化为指定位置 (x,y)。
我在渲染之前关闭当前子路径,并设置下一段的起始位置。
但是,如果您要画一条长线或多条线,您将遇到评论中链接中定义的主要性能问题。画一条很长的线,你就会明白我的意思。使用最少的线条绘制,您可能会摆脱当前的方法。
遗憾的是,使用 SKShapeNode
进行这种性质的绘制并没有达到应有的优化程度。
关于ios - 使用 Touch iOS Sprite Kit 画线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26043447/
我对这个话题有点怀疑。 情况: 我进行了一项研究,其中指出 Sencha Touch 2 (further Sencha) 和 DHTMLX Touch (further DHTMLX) 是可供选择的
我的移动应用程序目前在 Sencha Touch 1.1.1 下运行。现在,我想将其升级到 Sencha Touch 2.0。有人可以帮我做这件事吗?升级时我应该注意哪些一般步骤? 另外,是否有帮助该
在他们的文档中找不到指定了所有日期时间格式的位置? 我想要一个日期看起来像这样 13 Jan 2013 我发现了这个模式: date("F j, Y") 但这给了我很长的月份名称。 (不知道为什么他们
我需要一个简单的嵌套 ListView 示例。沿着这条线的东西...... (来源:roosteronacid.com) 当您单击一个项目时,您将转换(滑动)到包含另一个列表的下一个 View /卡片
scons 使用 MD5 哈希值而不是文件修改时间来确定是否需要构建依赖项。 我希望这是默认行为。但是,除了编辑文件以使其不同之外,是否有任何方法可以强制它假设特定文件已过期(相当于“触摸”)? 编辑
我有一个 sencha touch 显示在列表中的联系人列表。然后,当您单击列表中的姓名时,它应该向右滑动并说您好 {联系人姓名}!但是当它现在滑过时,它只是说你好!第 29 行是项目点击的 Acti
我是一名 Ext 老手,但我需要创建一些相当简单的移动应用程序,自然而然我正在研究 sencha touch。 Ting 是 - 大多数示例无法在 Firefox/Opera 中运行。 我很高兴使用
只是想知道在 Sencha Touch 中是否有处理该问题的方法。一个商店,应用不同的过滤器后,商店可以用于不同的地方。 例如: 我有一家商店: Ext.regModel('abc', { f
如何覆盖浏览器后退按钮的功能?我在页面中有导航 View ,我想同步浏览器后退按钮和导航 View 的后退按钮。我可以覆盖导航按钮的功能,但我不知道如何为浏览器返回做同样的事情。 我们将不胜感激。 最
如何使用两个 Action 创建 UIButton。 我知道通过使用 UILongPressGestureRecognizer 我们可以执行 Longpress。 但我的要求是,当我长按 UIButt
如何在 Ext.panel 中动态添加新项目?这是我正在使用的代码; app.views.ViewItem = Ext.extend(Ext.Panel, { id: '0', doc
我有一个全屏按钮(我将其放置在 IB 中),其中包含一个图像,当用户单击它时,我希望将其滑出屏幕。我知道连接正常,因为单击按钮时我可以记录一些内容。但是我之前用来移动 UIViews 和 UIImag
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be
大家好,我目前正在为 iPhone 开发一款节奏游戏,只是想知道是否有人对用于 react 时间的最佳作品有任何想法。 我已经完成了所有编码,并将其范围缩小到大约 2 种方式: 1:使用绕过 UICo
我正在尝试使用XCode编码计算器,但是后来我看到带有逗号的数字只是在逗号后被切掉了。 我正在用文本代码获取带有此代码的数字。 -(IBAction)Additionbutton:(id)sender
Sencha Touch 中是否有控件可以显示如下图所示的密码字段? 最佳答案 不,没有本地组件可以做到这一点。但是您可以自己构建它:它是一个包含 4 个输入字段和十几个按钮的表单。有关详细信息,请参
出于某种原因,我的表单面板没有显示。谁能帮忙?如果这很明显,我是新手,很抱歉!它是用 Sencha Architect 构建的,但我不明白为什么没有字段显示在表单中?... Ext.define('M
我创建了一个基于表格的模板,因此我可以获得类似网格的感觉。我的问题是,当我单击表格行时,如何弹出警报(带有 td 信息)。 这是我的 getUserList.js 文件 Ext.regMode
他们无论如何要更改圆形矩形按钮的白色部分而不制作自定义按钮吗? 最佳答案 嗯,差不多。您必须将其设置为自定义但不继承 UIButton。那么你应该能够做类似的事情 myButton.layer.cor
有人可以给我指点 Sencha Touch 和 Javascript 的初学者教程吗?我对 HTML 和 Javascript & CSS 知之甚少。我需要学习高级 Javascript 和指南针/主
我是一名优秀的程序员,十分优秀!