在工程图视图中正确实现块 [英] Correctly implement the blocks in the drawing view

查看:110
本文介绍了在工程图视图中正确实现块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在工程图视图中正确实现块,以便何时可以将线分为两部分。使用UIImageView还是UIImage?



在切割块之后,

解决方案

首先,总共可以削减多少次?会导致多少个独立的块? 10点100?在实施上述任何一项之前,请测试在iPhone或iPod touch上移动该数量的对象。仅仅因为它可以在模拟器上运行并不意味着它在实际设备上的速度就足够快。



第二,正如已经提到的,有一些游戏图形和物理库可能会为您完成很多工作。 Cocos2D 似乎是一种流行的选择,它结合了OpenGL绘图和相对容易访问的物理库。 p>

无论如何,要制作自己的绘图,有以下选择:


  1. 将所有图形移动到OpenGL。这不应该轻描淡写-您在Cocoa Touch中失去了很多工作上的便利。您还可以最大程度地控制图形和动画,如果花时间对其进行优化,则可以获得最流畅的性能。


  2. 具有一个UIView,添加对于每个独立块, CALayer 子层均位于其主层。 CALayers专为快速移动和合成而设计。但是,如果您正在运行物理模拟,则第一步将是删除其动画行为。 本教程系列可能有用。


  3. 每个块都有一个单独的 UIView 。这将与使用CALayer具有类似的性能,因为UIView实际上是使用CALayer绘制的。此选项将占用更多的内存(与以前相比,您至少具有更多的图层和更多的视图),但是您拥有CALayers的全部功能以及一些在视图上更容易的绘图选项。


  4. 具有一个 UIView ,并在其 drawRect 方法期间绘制每个块。这可能看起来很容易实现,但是几乎肯定会太慢。


如果有可能,请分别测试每个这些。在继续进行切割和物理部分之前,您可以在屏幕上放慢多少动画,然后再放慢速度?您可以用该游戏制作游戏吗?请记住,您的物理系统在运行时会降低游戏的运行速度。


How to correctly implement the blocks in the drawing view, so that when they could cut the line in two parts. Using UIImageView or UIImage?

After the cut blocks should fall under the influence of physics.

解决方案

First, how many cuts could happen in total? How many independent pieces of block could result? 10? 100? Before implementing any of these, test moving that number of objects around on an iPhone or iPod touch. Just because it works on the simulator does not mean it will be fast enough on the actual device.

Second, as already noted, there are libraries for game graphics and physics that may do a lot of the work for you. Cocos2D appears to be a popular option, combining OpenGL drawing with relatively easy access to physics libraries.

Anyway, to do your own drawing, here are the choices:

  1. Move all the graphics into OpenGL. This should not be undertaken lightly - you lose a lot of the ease of working in Cocoa Touch. You also have maximum control over your graphics and animation, and can achieve the smoothest performance if you take the time to optimise it.

  2. Have a single UIView, adding CALayer sublayers to its main layer for every independent block. CALayers are designed for rapid moving and compositing. However, if you're running a physics simulation, your first step will be to remove their animation behavior. This tutorial series may be useful.

  3. Have a separate UIView for each block. This will have similar performance to using CALayers, as UIViews are actually drawn with CALayer. This option will use up more memory, (you have at least as many layers and more views than before), but you have all of the power of CALayers plus a few drawing options that are easier on views.

  4. Have a single UIView, and draw every block during its drawRect method. This may look easy to implement, but it will almost certainly be too slow.

If at all possible, test each of these. Before you continue with the cutting and physics parts, how many blocks can you animate across the screen before it slows down too far? Can you make a game with that Remember that your physics system will slow the game down when it does work.

这篇关于在工程图视图中正确实现块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆