扩展 BitMap 类。 addChild() 会接受子类吗?
我想创建一个具有交互性并且可以保存图像的类。我希望它比 Sprite 类更轻,所以我正在考虑扩展 bitMap 类。如果我扩展 BitMap 类。将位图数据放入该类中并将其放置到舞台上。会出现吗???
I want to create a class that is interactive and can hold an image. I want it to be lighter then the Sprite class, so I was thinking about extending the bitMap class. If I extend the BitMap class. put a bitMap data in that class and at it to the stage. would it appear ???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我非常怀疑它会比 Sprite 轻得多,因为如果您遇到性能问题,它可能更多地与显示列表中存在大量显示对象有关,而不是与这些显示对象的类型有关。
但回答你的问题,是的。任何扩展 DisplayObject 的对象都可以添加到显示列表中。 Bitmap 继承自 DisplayObject,因此如果您扩展 Bitmap,您的类也会扩展。
I greatly doubt that it will be much lighter than a Sprite, because if you are experiencing performance troubles, it probably has more to do with having a lot of display objects in your display list, rather than the type of those display objects.
But to answer your question, yes. Any object extending DisplayObject can be added to the display list. Bitmap inherits from DisplayObject, so if you extend Bitmap, so will your class.