简体   繁体   English

Container和DisplayObjectContainer有什么区别?

[英]What is the difference between Container and DisplayObjectContainer?

I am using a JavaScript library called PIXI and am looking for a way to "zoom" in my game. 我正在使用一个名为PIXI的JavaScript库,我正在寻找一种在我的游戏中“缩放”的方法。 A search on the internet suggested that I put everything inside a DisplayObjectContainer and then resize it to simulate a zoom-effect. 在互联网上搜索建议我将所有内容放在DisplayObjectContainer ,然后调整其大小以模拟缩放效果。

The thing is that I already have Container (aka stage ), and I think that is resizable too. 问题是我已经拥有Container (又称stage ),我认为它也可以调整大小。 So I don't understand the reason behind using a DisplayObjectContainer when you have a Container already. 所以我不明白当你有一个Container时使用DisplayObjectContainer背后的原因。 And frankly, I don't even see the difference between them. 坦率地说,我甚至看不出它们之间的区别。

This page says the following about DisplayObjectContainer : 此页面显示以下有关DisplayObjectContainer

A DisplayObjectContainer represents a collection of display objects. DisplayObjectContainer表示显示对象的集合。 It is the base class of all display objects that act as a container for other objects. 它是所有显示对象的基类,充当其他对象的容器。

This other page says the following about Container : 这个其他页面说明了关于Container

A Container represents a collection of display objects. Container表示显示对象的集合。 It is the base class of all display objects that act as a container for other objects. 它是所有显示对象的基类,充当其他对象的容器。

The only possible scenario I can imagine is that one of these container-objects is outdated and belongs to an older version of PIXI, which isn't too unrealistic since PIXI is rather new and could change a lot. 我可以想象的唯一可能的情况是这些容器对象中的一个已经过时并且属于较旧版本的PIXI,这不是太不现实,因为PIXI相当新,并且可能会发生很大变化。 But this is just a guess. 但这只是猜测。

The guess is correct. 猜测是正确的。 DisplayObjectContainer is outdated and replaced with Container . DisplayObjectContainer已过时并替换为Container

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM