Is it possible to Draw something without adding any entities to the world?
[SOLVED] Is it possible to Draw something from World class?
Yep.
public class RenderWorld extends World {
override public function render():void {
Draw.circle(20, 50, 10, 0xff00ff);
super.render();
}
}
thanks thanks thanks… also, i’ve another delicious question.
can i create my own render function without using class’s own render function…
override public function update():void
{
renderHere(100,100);
}
private function renderHere(x:Number, y:Number):void
{
Draw.circle(x+20, y+50, 10, 0xff00ff);
}
i know that’s looking unnecessary and there are lots of ways make what i want but i’ll feel better if i can seperate some renderings as functions…
I think i got it know… it is possible… but i can’t use it while another render function working… because of z depth layer sorting feature…
Why not just override world’s render() method like so:
override public function render():void
{
super.render(); //this line is vital
renderHere(100,100);
}
private function renderHere(x:Number, y:Number):void
{
Draw.circle(x+20, y+50, 10, 0xff00ff);
}
This should make your circle be rendered last.
Woah! :S :S
You mean Draw function works outside of render class? holy god… why the hell i’m learning the most important things so late! :S thanks for this, i’m gonna try it
You can also add just a graphic to the world (which will then construct an entity etc) with the world.addGraphic() function.
I’d say in general it’s a good idea to try to stick to entities as much as possible; it helps keep your code nicely laid out for one thing. I even put full screen effects in entities; it comes in handy in instances where, for example, you want it to appear above the game but below the HUD (and the game and HUD are made up of entities on different layers).
You can do the same Draw.circle in a render() override in an entity too!