--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
You should check for Ludum darev games methods or some "timing a game" tut. The subject goes well beyond the scope of this mailing list.
Xoxo
yoOBFUSCATEDpierbover.com
+1 don't draw bitmaps.
Animate bitmap objects, or use Graphics API (and don't forget to .clear when you redraw).
Don't use bitmapData.draw. It uses software rendering and it is slow... regular bitmaps should be faster. Also don't use if you cacheAsBitmap, it also triggers software renderingSwitching to tilesheet should be relatively simple, logic is similar to bitmapData.draw and performance gains are huge, especially in your case when you have a lot of tiles. You can also have scrollrect on tilesheet. Also, you only draw tiles that should be visible similary to your current method, just populate an array only with tiles that should be visible
I concur. Let s fire some advices :
Switch to tilesheet, prototype in flash target to iterate fast, start with a small viewport, dont forget to interpolate by calculating delta between frames, snap pixel coordinates to integers to avoid sub sampling, go 30fps at first and start by making a small sprite loop smooth, then expand.
Paradoxally in flash, scrolling is always hard to get right because it is not well suited to do it.
Xoxo
Don't use bitmapData.draw. It uses software rendering and it is slow... regular bitmaps should be faster. Also don't use if you cacheAsBitmap, it also triggers software renderingSwitching to tilesheet should be relatively simple, logic is similar to bitmapData.draw and performance gains are huge, especially in your case when you have a lot of tiles. You can also have scrollrect on tilesheet. Also, you only draw tiles that should be visible similary to your current method, just populate an array only with tiles that should be visible
Djole: My my! I was so much in the code I forgot about sw/hw rendering! Will go for Tilesheet then indeed, and let the community (and future reader newbies like who I am now :) know. Thank you!
Philippe: I use copyPixel. I assume by "draw" both you and Djole mean that.
I read it was fast and seen it working in Nicolas' ludum Evoland code (however, my map is much larger so cannot load everything in one go as first, that would be suicidal and second, there are technical limitations of pic.data storing objects. So I really must build "tilesets" on the fly).
Call me a newbie, but what do you mean by "animating bitmaps" (scrollRect? tried that, same result)?
And by "graphics API"? I'm using container's .graphics.beginBitmapFill() in both test "a" and "b" I mentioned.
Could you please give just a pinch more details please so I can google up and learn more about this?
Thank you guys again!
Mark
You received this message because you are subscribed to a topic in the Google Groups "Haxe" group.
If you use tilesheet don't test in flash, test in neko :)
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
Found this as of now: https://groups.google.com/forum/m/#!msg/Haxelang/Im4ddJx7lJY/DrniHbaD2D4J
So basically, they say, openfl always try to use hardware render but only TileSheet do tricks like batching or caching (and probably magic too :).
And my method, using ".copyPixels" and ".graphics" is the slowest possible way for desktop...
However, it is fast in flash.
Probably this is why Nicolas uses it in Evoland ludum code (flash/web based), and I technically shot myself in the leg going with it for desktop... Bull's Eye! :D
I'm very tired and just messing up things now. Must sleep. The will is strong but the flesh is weak :P
But tomorrow I'll learn into TileSheet, read it's code and rewrite my drawing. Will let the community know if it smooths things up or still sloppy.
You received this message because you are subscribed to a topic in the Google Groups "Haxe" group.
All the BitmapData methods (draw and copyPixels) are CPU (software) and slow-ish because the bitmap has to be (re)uploaded to the GPU for rendering.
Using Graphics API, drawing rectangles/triangles filled with colours or bitmaps is fast. Moving Bitmaps is about the same.
Using a Tilesheet *can* be faster if you use it to "batch" many draw instructions for the same texture. Doing many Tilesheet calls won't be faster than other methods.
var myTS : Tilesheet = null;
[init]
myTS = new Tilesheet(Assets.getBitmapData("assets/tilegfx.png'));
myTS.addTileRect(new Rectangle( 0, 0, 64, 64));
myTS.addTileRect(new Rectangle( 64, 0, 64, 64));
myTS.addTileRect(new Rectangle(128, 0, 64, 64));
myTS.addTileRect(new Rectangle( 0, 64, 64, 64));
myTS.addTileRect(new Rectangle( 64, 64, 64, 64));
myTS.addTileRect(new Rectangle( 0, 128, 64, 64));
//diffY == delta time
public function pE_ReDraw_TILESBASED(diffY : Int) : Void {
heroPos -= diffY;
var p0 : Point = new Point(0,0);
p0.y = [calculated: some pixel within a single tile, so 0-64]
//I also find out here how many tiles should be above and below the hero;
//depending on the amount of pixels the hero moved, which for now is "diff"/delta.
//This should be fast as I declare 3-4 Ints and do up to 10 basic math ('+, -, *, /')
var tD : Array<Float> = []; //tileData array for drawTiles() call
//topTile & bottomTile, e.g. 80-91 (11 rows), calculated and declared above
for (rrow in topTile...bottomTile) {
var ifrom : Int = 11 * rrow; //11 tiles in a row
for (ttile in ifrom...ifrom + 11) {
tD.push(p0.x);
tD.push(p0.y);
tD.push(mapData[ttile] - 1); //above mentioned array with 1211 elements
//-1 as addTileRect goes from 0, csv from 1
p0.x += 64;
}
p0.x = 0;
p0.y += 64;
}
this.graphics.clear(); //the class extends Sprite
myTS.drawTiles(this.graphics, tD, true);
}
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
--
Philippe
it is fast. cpu is on 2-4%, my app eats about 25mb ram alltogether (debug build)... gpu for some reason has high utilization but not heating so I assume clock is not peaked.
the pc is an old notebook so this should be ok-ish (gpu is suspicious but it's an integrated radeon 6720M or something similar)
my problem is what I explained and can be seen on vid: lack of smoothness / blurred textures on high speed scrolling.
tried on a *somewhat* better pc (I'm a poor person :), same thing there. maybe even worse / blurry scrolling.
I'll share the test app when it's ready and you guys can see it for yourself.
...
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
Depending how your app is built, you could use conditional compilation for code that is not shared between platforms. I did an AIR app for desktop/mobile, video playback required native extensions on mobile for performance. Adobe Scout is great and really helps you see where problems occur in your code :)
--