问题标签 [anchorpoint]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
android - 无法为 andEngineGLES2-AC 中的精灵设置 .setAnchorCenter() 和 .setRotationCenter()
我有一个想要在 touchevent 上移动的精灵。应该有一种箭头指向计划运动的方向。运动应该在 Action_Up 9 上运行)。问题在于旋转中心和锚点中心。它应该是这样工作的:当您触摸精灵时,会出现箭头和蓝色圆圈(稍后箭头的数量将取决于手指与显示运动强度的精灵的距离)。第一个箭头连接到精灵,另一个箭头连接到第一个,依此类推。因此,当您移动手指时,第一个箭头底部的中心应该围绕我的精灵的中心旋转。(我希望它清楚,它与愤怒的小鸟类似的概念,您可以移动手指来瞄准并设定力量)。问题是我无法设置坐标。例如设置坐标(50f,50f) 用于旋转中心或锚中心使我的箭头围绕远离精灵中心的点移动。我认为将坐标除以 32 会有所帮助,但没有。甚至像 (0.5f, 0.5f) 这样的坐标也会使我的箭头移动超过 0.5 像素。我正在使用andEngine GLES2-AnchorCenter
编辑:
当我使用时有效的是:
并且没有设置锚点中心。
为什么我需要 X 和 Y 的值低于 1f 作为旋转中心?
ios - 移动场景:更新方法中的 SKAction 动画或锚点?
我的游戏基于并排的两个屏幕(A 和 B),但设备屏幕一次只能显示其中一个。
例如,A 位于 (0, 0) 位置,B 位于 (320, 0)
我尝试了两种从 A 切换到 B 的解决方案:
- 首先,我将整个场景放入一个节点,即 MainNode。要从 A 切换到 B,只需将 MainNode 位置设置为 (0, -320)。
- 其他解决方案,更优雅的恕我直言(但不适用于使用Coco2D库的 LearnCoco2D),是将场景锚点移动到 (0, -1)
现在,如果我想通过动画从 A 转到 B,则必须调整这两种解决方案:
通过使用 SKAction
[Main runAction:[SKAction moveToY:-320 duration:0.1]];
通过在
update
方法中为 anchorPoint 设置动画if(anchorY > -1) anchorY -= 0.1;
这两种解决方案有效(尽管线性 SKAction::timingMode 不能正确呈现线性平移),但我想知道哪个在优化和优雅方面是最好的。欢迎提供文档;)
编辑:
显然,我的问题不清楚(可能是由于我的英语水平)。
简而言之,我的问题是:滚动场景的最佳实践到底是什么?
ios - 如何在IOS中制作月亮绕地球自转同时自转的CAAnimation效果?
我知道在IOS中创建月球绕地球转的效果很简单。假设月球是一个 CALayer 对象,只需将该对象的 anchorPoint 更改为地球,它就会动画围绕地球旋转。但是如何创造同时自转的月亮呢?由于月亮只能有一个锚点,看来我不能再让这个CALayer对象自行旋转了。你们有什么感想?谢谢。
ios - 如何更改 UICollectionViewLayoutAttributes 中转换的锚点?
我正在使用UICollectionViewLayoutAttributes
对我的一个单元格进行转换。
我想应用的转换是
用数字dx
,dy
和.rx
ry
问题是这个表达式对于anchorPoint
不是我的单元格中心的是可以的。好像默认anchorPoint
是中间的。所以,我想指定我attributes
的anchorPoint
.
有没有办法做到这一点?
PS:除了属性之外,我对转换我的单元格没有太多控制权。实际上,这个变换被应用在方法中- (UICollectionViewLayoutAttributes*)initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)itemIndexPath
java - RotateBy Anchorpoint 不影响旋转
在 Cocos2d (Android, JAVA) 中,我使用 CCRotateBy 来旋转一个 CCNode,其中包含多个图块作为子节点。我想使用中心瓷砖的中心作为旋转点,所以我想我会使用 Anchorpoint。
但是,我给锚点赋予什么值并不重要,瓷砖会一直围绕我的屏幕左下角旋转。怎么来的?
(瓦片是CCNodes,收集在两个列表中,tilesSelected和secondaryTilesSelected)
swift - 获取相对于其中心的对象位置,无论使用的锚点如何
无论父对象锚点是什么,有没有办法相对于另一个对象中心点(准确地说,以对象为中心)定位对象?
考虑以下场景,我们希望将对象 B 放置在对象 A 的中心
换句话说,我试图找出是否有人有他们使用的算法或系统能够将一个对象相对于另一个对象中心(在另一个对象的中间)定位,而不管任何一个对象的锚点是什么当时正在使用。
谢谢
swift - Swift SKPhysicsJointPin 和场景锚点
我在我的 SpriteKit 游戏中添加了一根绳子,一切正常。但是,如果我将场景锚点更改为 (0.5, 0.5),绳子的每一段都会掉落。如果我把它留给 (0, 0) 一切都好。即使我将锚点更改为(0.5,0.5),有什么方法可以使绳索正常工作吗?非常感谢!
ios - Positioning sublayer on center of animated UIView
I have a UIView shaped like a circle that expands and contracts. I need to have a sublayer positioned at its center that stays the same size as it is animating. The code below contains four sample views showing things I have tried. It can be copied and pasted as is.
- The first UIView is a not animated. Its sublayer is positioned at its center, but it has to be positioned relative to the UIView's origin. This is a problem when UIView's bounds and origin is changing during an animation.
- The second UIView has two animations: one for
@"bounds"
and one for@"cornerRadius"
. This arrangement causes the sublayer to end up at the screen's origin (top left). - The third UIView also has two animations: this time for
@"bounds.size"
and@"cornerRadius"
. The sublayer stays the same size, which is good, but it does not stay at the center of the UIView. I tried to use[thirdView.layer setNeedsDisplayOnBoundsChange:YES];
to compensate for the bounds change but it didn't work. I also triedthirdView.contentMode = UIViewContentModeRedraw;
. - The fourth UIView has one animation for
@"transform.scale"
, which seems to be a bit more efficient as far as expansion animations go. The sublayer stays at the center of the UIView like I want it, but it does not stay the same size. I need to have the size of the sublayer be independent because I intend to animate it.
Here's all the code. It looks like a lot but it's some pretty simple stuff.
Since changing the origin of the UIView isn't possible, I need to find out a way to do either one of these things:
- Consistently update the sublayer's position to compensate for a changing origin.
- Make it so that the sublayer's size on the fourth example does not change as the UIView is scaling.
I can't do multiple UIViews because I intend to add the entire layer to an MKAnnotationView.
Thanks!
ios - 更改锚点后如何调整图像位置?(迅速)
我正在使用UIGestureRecognizer
进行捏合动作,我需要更改锚点以调整到我的正确点UIImage
。更改锚点后,图像移动了一点,我需要将其放回原点。这是我正在做的事情:
但是图像不会改变原点或大小......我做错了什么?
ios - 更改(精灵)节点的锚点时位置更改
我正在向它添加主节点和子节点。所有节点都应该从一个可变锚点旋转。
所以当我改变主节点的锚点时,子节点和主节点之间的距离正在改变(子节点之间的距离保持不变)。
为什么会发生这种情况,如何解决?
编辑:2015 年 6 月 5 日
在这里我画出我的情况。主片的锚点是 (0.5, 0.5)。所以当我改变 zrotation 时,整条路都会绕着主要部分转。然后我将锚点更改为第二块(子),因此主要部分的锚点变为(0.5,1.5)。但是当我这样做时,主要部分向下移动,我仍然没有我想要的旋转点..
我怎样才能做到这一点?