开发者

How to fix an imageView to another and move both together?

I'm developing a game in which I have a bow and arrow. I have to move b开发者_如何学Gooth bow and arrow imageViews on touch through different angles for which I'm applying CGAffineTransform.

The problem is this that after rotation, bow and arrow change their positions, so the arrow does not stay at the center of the bow. I want to fix this arrow at the center point of bow and move along with the bow.

I'm applying the same angles to both bow and arrow, but it seems that the bow is changing its center after transform. While detecting touch, I'm needed to provide the touch position to arrow throgh its center, so I even cant use the center property of arrow to fix it at a certain point.

Can anybody please help me? It's really urgent.


I would place both UIImageViews in a container UIView and rotate that instead. This will keep the bow and arrow together. I hope I'm understanding your requirements correctly. You can also look into the CALayer anchorPoint property which will affect which point the view is rotated around. Changing it will move the view though, so you do need to compensate for this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜