2012-05-29 25 views
3

我正在使用Starling Framework构建Flash for iOS游戏。我也在使用Nape这个2D物理引擎。我遇到的问题是Nape引擎使用flash.display.DisplayObject的特定方法,但是,因为我使用的是Starling框架,所以我不得不使用starling.display.DisplayObject。它返回此错误:Starling,Nape,Flash,Haxe Dillemma

1067: Implicit coercion of a value of type flash.display:DisplayObject to an unrelated type starling.display:DisplayObject.

无法调整此方法。 Nape引擎被编译成一个.swc文件,我无法编辑。这个引擎也是开源的,但它是在Haxe中完成的,我不知道如何在编辑它之后编译它。

源可以在这里下载:http://deltaluca.me.uk/docnew/

我需要改变所有的nape.utils.Debugflash.display.DisplayObjectstarling.display.DisplayObject

如果你可以借我任何建议,我会非常感激。

+0

你在使用什么操作系统? Nape看起来像是想在* nix系统上编译。 –

回答

1

这是我做的,很简单。如果您还有其他问题,请告诉我。

在创建空间 - 通常当场景创建:

/** 
* 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; 
} 
3

希望您知道调试应用程序仅用于调试目的。最后不要使用nape.utils.Debug来渲染你的空间。

我正在做starling + nape游戏。我在我的空间中遍历实体并读取它们的x,y旋转值,以在我的舞台上呈现Starling的Images和MovieClip。我想说的是,使用Starling编写自己的“调试绘图”非常简单。总之,你必须写一些,因为nape.utils.Debug仅用于调试目的;)。

+0

谢谢,我会看看:) – CptRayMar