StarlingGraphics / Starling-Extension-Graphics

flash.display.Graphics style extension for the Starling Flash GPU rendering framework
https://github.com/StarlingGraphics/Starling-Extension-Graphics/wiki
MIT License
282 stars 89 forks source link

AIR related issue #104

Open darie8208 opened 10 years ago

darie8208 commented 10 years ago

Hi guys. If you could help me with my problem I would be really grateful. I am working on a game in which one cuts pieces off a rock. I got the texture of the rock and I am attaching the corresponding part of the texture to the pieces that come off the rock. The pieces are defined as GeomPoly. Each piece should have a contour and the corresponding texture from the rock.

When I compile the code in Flash everything is fine.

When I compile the code in AIR, the texture in the pieces is invisible, but the contour lines are visible. Would you know what could cause this issue?

Here is an outline of the code:

graphics.beginTextureFill(rockTexture) var iterator:GeomVertexIterator = poly.forwardIterator() var v1:Vec2 = iterator.next() graphics.moveTo(v1.x , v1.y ) while (iterator.hasNext()) { var v:Vec2 = iterator.next() graphics.lineTo(v.x , v.y ) } graphics.lineTo(v1.x , v1.y ) graphics.endFill()

Any help would be greatly appreciated.

Thanks in advance, Darie

IonSwitz commented 10 years ago

I am sorry that I haven't responded earlier, but unfortunately I have no clue what can be wrong here.

What environment do you use to build it? Would it be possible to share your project files for both projects, so we can try to reproduce it?

darie8208 commented 10 years ago

Hi,

Thank you for answering and sorry for my late reply.

Unfortunately I cannot share the project files, it is quite a big project.

I use Flashdevelp with which I compile the project either to a swc file or to the ipa file (app for iOs).

Here is what I found today and how I solved my issue, hope it helps you too:

When the AIR compiler is used, that generates the ipa file, only triangles can be filled with texture.

If I do a square like this: graphics.beginTextureFill(rockTexture) graphics.moveTo(0, 0) graphics.lineTo(1, 0) graphics.lineTo(1, 1) graphics.lineTo(0, 1) graphics.lineTo(0,0) graphics.endFill()

The square would look fine when I run the swc file, but would be empty when using the ipa file on the iPad.

To solve this issue I triangulate the shape and fill each triangle individually, but this seems to be expensive.

I did not look at your code to check if you triangulate geomPolys for beginTextureFill, but if you do that, maybe there is a problem with that, that AIR does not understand.

I apologise if I am not clear about the AIR, ipa file stuff, but I am quite new to these technologies, I was recently hired as a graduate for this position.

Darie

IonSwitz commented 10 years ago

I really have no good answer here. Sorry. I haven't done any development on iPads or mobile platforms at all. There are others here who might help you, though.