PhasedEvolution Posted October 22, 2016 Share Posted October 22, 2016 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 The_dude8080 1 Link to comment Share on other sites More sharing options...
Milton Posted October 22, 2016 Share Posted October 22, 2016 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 More sharing options...
PhasedEvolution Posted October 22, 2016 Author Share Posted October 22, 2016 @Milton Hey Milton :p. I don't think I forgot that... I have it in the BulletVsLand function. Anyway I have put it also in the create function.Can't make it work though. Link to comment Share on other sites More sharing options...
Milton Posted October 22, 2016 Share Posted October 22, 2016 Works for me. Add it after wall_bmd.ctx.fill(); Logging when hitting the wall gives me: pixel? Object {r: 0, g: 0, b: 0, a: 1, h: 0…} pixel? Object {r: 255, g: 160, b: 122, a: 255, h: 0…} if(collision_pixel.a > 255) is not going to work, 255 is max. PhasedEvolution 1 Link to comment Share on other sites More sharing options...
PhasedEvolution Posted October 22, 2016 Author Share Posted October 22, 2016 @Milton Well it really works nice 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 More sharing options...
Milton Posted October 22, 2016 Share Posted October 22, 2016 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... PhasedEvolution 1 Link to comment Share on other sites More sharing options...
PhasedEvolution Posted October 23, 2016 Author Share Posted October 23, 2016 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 More sharing options...
Milton Posted October 23, 2016 Share Posted October 23, 2016 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 More sharing options...
PhasedEvolution Posted October 23, 2016 Author Share Posted October 23, 2016 @Milton thanks I did a brief search and OpenFL seems quite pleasent; will need to get used to that type of language though. But people seem to like it a lot :p. And I suppose that, as you said, it does bring advantages. As for the community, tutorials, is it good? Link to comment Share on other sites More sharing options...
Milton Posted October 23, 2016 Share Posted October 23, 2016 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 More sharing options...
PhasedEvolution Posted October 23, 2016 Author Share Posted October 23, 2016 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 More sharing options...
Milton Posted October 23, 2016 Share Posted October 23, 2016 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. PhasedEvolution 1 Link to comment Share on other sites More sharing options...
PhasedEvolution Posted October 23, 2016 Author Share Posted October 23, 2016 I see. Will look into instalation and tutorials and try it out. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts