Jump to content

Phaser destroy bitmap (1.3)


PhasedEvolution
 Share

Recommended Posts

Hello. I have made previous threads about this specific issue but couldn't get my problem solved.

This time I made a codepen with my code which might make helping easier: https://codepen.io/PhasedEvolution/pen/mAaNkp?editors=1010

I want to make something similar to this: http://codepen.io/photonstorm/pen/ogZJPP?editors=001

However I am not being able to destroy the bmd I created and I don't know why... Can someone look into this and help me out?

Cheers

Link to comment
Share on other sites

Did you forget 

wall_bmd.update();

?

Quote

If you have drawn anything to the BitmapData since it was created you must call BitmapData.update to refresh the array buffer, otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist.

 

Link to comment
Share on other sites

@Milton Well it really works nice :P However when I change my code to this : https://codepen.io/PhasedEvolution/pen/mAaNkp?editors=1011 it doesn't work anymore.

I have tryed everything but I don't know why it doesn't work. The code I showed before was the simplified version of my actual code but I guess the problem wasn't there. It must be something related to the way I am "Pooling" my bullets (that is also making the game extremelly slow) I need a better way to do it. I am not sure if I can use phaser already made collision/overlap functions for this... But the biggest problem is really that. Why the bmd is not getting destroyed

 

Link to comment
Share on other sites

This sort of works:

if(get_collision_pixel.a == 255) { 
  bomb.x = 0; // or actually remove bomb
  //wall_bmd.blendDestinationOut();
  //wall_bmd.ctx.rect(bomb_x, bomb_y, 30,30);
  wall_bmd.circle(bomb_x, bomb_y, 10, 'rgba(0, 0, 0, 254');
  //wall_bmd.blendReset();
  wall_bmd.dirty = true;
  wall_bmd.update();     
}

The 'dirty' flag is the key I think...
Not sure how the other example triggers it...

Link to comment
Share on other sites

10 hours ago, Milton said:

This sort of works:


if(get_collision_pixel.a == 255) { 
  bomb.x = 0; // or actually remove bomb
  //wall_bmd.blendDestinationOut();
  //wall_bmd.ctx.rect(bomb_x, bomb_y, 30,30);
  wall_bmd.circle(bomb_x, bomb_y, 10, 'rgba(0, 0, 0, 254');
  //wall_bmd.blendReset();
  wall_bmd.dirty = true;
  wall_bmd.update();     
}

The 'dirty' flag is the key I think...
Not sure how the other example triggers it...

I will try to figure that out. You were a great help once again @Milton Thanks

Link to comment
Share on other sites

Hi Phased.

I really like your questions, you are on the right track :)
My advice to you would be, switch to Haxe/OpenFL.
I know it's quite an investment, but switching to a statically typed language is worth it...
You get your errors before you run, that'll help you a lot ;)

Link to comment
Share on other sites

http://haxecoder.com/ is excellent, but I think it needs some older libraries. If you can install openfl 3.6.0 and lime 2.9.0 you should be good to go ( You can set versions with haxelib set).

Haxe/OpenFL is almost the same as Phaser. The same Flash people are involved. It's mostly based on Flixel. You could try HaxeFlixel to get started, that should be very familiar.

Link to comment
Share on other sites

47 minutes ago, Milton said:

http://haxecoder.com/ is excellent, but I think it needs some older libraries. If you can install openfl 3.6.0 and lime 2.9.0 you should be good to go ( You can set versions with haxelib set).

Haxe/OpenFL is almost the same as Phaser. The same Flash people are involved. It's mostly based on Flixel. You could try HaxeFlixel to get started, that should be very familiar.

Oh nice. I just got a little confused over all the concepts (Haxe, OpenFL, HaxeFlixel). What I understood from searching was something like this: Haxe is a programming language that shares similarities with C# ,for example. OpenFL was built on haxe and has something to do with compiling flash to multiple platforms? HaxeFlixel was built based on OpenFL and it is focused on game development? You said I could use HaxeFlixel to get started. Does that bring limitations in comparison to just use Haxe/OpenFL for instance? I am not sure if this question makes any sense though...

Link to comment
Share on other sites

I wouldn't compare Haxe to C#. C# is like Java. I am a certified (Oracle) Java developer, and I hate it. Haxe, like JavaScript and Flash (ActionScript), is based on (similar to) ECMAScript.
The fun thing about Haxe is that it compiles to most any other language. You don't have to worry about that though. Write once, and then just say, I'd like to have this in Javascript, C, PHP, Java, whatever...

OpenFL justs gives you a very Flash like API, Displaylists, Sprites etc.
HaxeFlixel is like Phaser, a pretty complete game engine.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...