我正在使用Starling Framework在Flash for iOS中构建游戏。 我也在使用Nape,一个2D物理引擎。 我遇到的问题是Nape引擎上的一个特定方法使用flash.display.DisplayObject ,但是,因为我使用的是Starling框架,所以我必须使用starling.display.DisplayObject 。 它返回此错误:
1067:flash.display类型值的隐式强制:DisplayObject为不相关类型starling.display:DisplayObject。
无法调整此方法。 Nape引擎被编译成.swc,我无法编辑。 引擎也是开源的,但它是在Haxe中完成的,我编辑后无法弄清楚如何编译它。
来源可以在这里下载: http : //deltaluca.me.uk/docnew/
我需要将nape.utils.Debug类中的所有flash.display.DisplayObject更改为nape.utils.Debug 。
如果你能借给我任何建议,我会非常感激。
I am building a game in Flash for iOS using the Starling Framework. I am also using Nape, a 2D Physics engine. The problem I am experiencing is a particular method on the Nape engine uses flash.display.DisplayObject, however, because I am using the Starling framework, I instead have to use starling.display.DisplayObject. It returns this error:
1067: Implicit coercion of a value of type flash.display:DisplayObject to an unrelated type starling.display:DisplayObject.
There is no way to adjust this method. The Nape engine is compiled into a .swc, which I am unable to edit. The engine is also open source, but it is done in Haxe, and I cannot figure out how to compile it once I have edited it.
The source can be downloaded here: http://deltaluca.me.uk/docnew/
I need to change all the flash.display.DisplayObject in the nape.utils.Debug class to starling.display.DisplayObject.
If you can lend me any advice I'd be really greatful.
最满意答案
这就是我做的,非常简单。 如果您还有其他问题,请与我们联系。
在创建场景时创建Space -typically:
/** * Create debug drawing space to overlay on assets if flag enabled in Release config */ if(Release.DEBUG_PHYSICS){ _debug = new ShapeDebug(320*2, 480*2, 0x000000); _debug.drawConstraints = true; _debug.drawCollisionArbiters = true; var MovieClipDebug:MovieClip = new MovieClip(); MovieClipDebug.addChild(_debug.display); Starling.current.nativeOverlay.addChild(MovieClipDebug); }舞台被摧毁时:
if(Release.DEBUG_PHYSICS){ _debug.clear(); _debug = null; }当图形引擎更新时:
/** * Update the positions of the depug layer */ if(Release.DEBUG_PHYSICS){ _debug.clear(); _debug.draw(_space); _debug.flush(); _debug.display.x = this.x; _debug.display.y = this.y; // handles camera zooming in/out _debug.display.scaleX = this.scaleX; _debug.display.scaleY = this.scaleY; }Here is what I do, pretty simple. Let me know if you have any more questions.
When creating the Space -typically when the scene is created:
/** * Create debug drawing space to overlay on assets if flag enabled in Release config */ if(Release.DEBUG_PHYSICS){ _debug = new ShapeDebug(320*2, 480*2, 0x000000); _debug.drawConstraints = true; _debug.drawCollisionArbiters = true; var MovieClipDebug:MovieClip = new MovieClip(); MovieClipDebug.addChild(_debug.display); Starling.current.nativeOverlay.addChild(MovieClipDebug); }When the stage is destroyed:
if(Release.DEBUG_PHYSICS){ _debug.clear(); _debug = null; }When the graphical engine updates:
/** * Update the positions of the depug layer */ if(Release.DEBUG_PHYSICS){ _debug.clear(); _debug.draw(_space); _debug.flush(); _debug.display.x = this.x; _debug.display.y = this.y; // handles camera zooming in/out _debug.display.scaleX = this.scaleX; _debug.display.scaleY = this.scaleY; }更多推荐
发布评论