How to tile without addGraphic(), or addGraphic is cool for my situation? [SOLVED]


(Bora Kasap) #1

Imagine the Z is a rectangle has height and width values as multiples of 16px.

So i have a world containing lots of Z rectangles all have sizes like 16x128 or 32x32 or 256x512 or …

And i have a 16x16 PNG file for tiling them.

I’m able to do this with world.addGraphic() for now. (by adding lots of 16x16 graphics over rectangles)

But i’m curious about, is that makes lack of performance because of too much graphic entities.

I just wanted to ask, is there any way to create a BitmapData with code which able to create any bigger BitmapData to add a single graphic for each rectangle object?

Or world.addGraphic is cool for this?

NOTE: I’m not using grid system for collisions, i wasn’t need that, everything’s cool about collision and performance at the moment. But i’m using Ogmo, first time, and i’m really really regretful about not used Ogmo for my previous game, as @jacobalbano suggested.


(Bora Kasap) #2

oh, i think i can use getPixels() and setPixels() to do this. I love flashpunk! :smiley:


(Bora Kasap) #3

hey guys i’m trying to use TiledImage class but it doesn’t get my embed png as a class, it results with “Invalid source image.” error which generated by flashpunk

[Embed(source = "src/assets/gfx/block16.png")] public static const block16:Class;

public static function block(width:int, height:int):TiledImage
{
   var block:TiledImage = new TiledImage(block16, width, height);
   return block;
}

(Bora Kasap) #4

SOLVED: Quick question, bitmapdata invalid : console & new world