Starling,Nape,Flash,Haxe Dillemma(Starling, Nape, Flash, Haxe Dillemma)

编程入门 行业动态 更新时间:2024-10-28 10:27:35
Starling,Nape,Flash,Haxe Dillemma(Starling, Nape, Flash, Haxe Dillemma)

我正在使用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; }

更多推荐

本文发布于:2023-08-01 13:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1359362.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Nape   Starling   Flash   Dillemma   Haxe

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!