Sign in to follow this  
PhasedEvolution

Phaser create hitboxes in isometric

Recommended Posts

Hello. I was able to create a hitbox on non-isometric as so:

 hitboxes = game.add.group();
 hitboxes.enableBody = true;  
 var new_dude = game.add.sprite(250,150,"walking_dude");
 new_dude.scale.x = 2;
 new_dude.scale.y = 2;
 new_dude.addChild(hitboxes);   
 hitbox1 = hitboxes.create(0,0,null);
 hitbox1.body.setSize(65,70,77,5);

 // basically a no-image sprite with physics body  fixed to a character

I can't translate this using isometric plugin because the cube doesn't get fixed to the character as it should. It falls to the ground. What is the actual difference between the two codes? Why does the first gets fixed to character and the second doesn't? I am on this mistery for hours


hitboxes = game.add.group(); 
new_dude = game.add.isoSprite(30, 30, 0, 'walking_dude',0); 
new_dude.scale.x = 2; 
new_dude.scale.y = 2; 
new_dude.addChild(hitboxes);
hitbox1 = game.add.isoSprite(30,30,0,null,0,hitboxes);
game.physics.isoArcade.enable(hitboxes);
hitbox1.body.setSize(300,300,300);

The isometric plugins http://udof.org/phaser/iso/doc/Phaser.Plugin.Isometric.html

Share this post


Link to post
Share on other sites
2 hours ago, Milton said:

I would guess this is an isoArcade bug.
Try hitbox1.body.allowGravity = false;

I think I found the major problem. Yep you allowGravity actually helped. The biggest problem is that I am not sure if it is possible to add isoSprites to other isoSprites as children. I would need that to make the hitbox move along the player. I am now using this code:

hitboxes = game.add.group();
hitboxes.enableBody = true;
hitboxes.physicsBodyType = Phaser.Plugin.Isometric.ISOARCADE;  
hitbox1 = game.add.isoSprite(0,0,0,null,0,hitboxes);
hitbox1.body.allowGravity = false;
hitbox1.body.setSize(100,100,100);

dude.addChild(hitboxes);  // I think this is the problem: dude is an isosprite and the child of hitboxes, hitbox1, is a isosprite too.
 

ssssssr.PNG

As you can see it is not associated to the player. However when I do it without isometric it gets a fixed-to-player position,

  hitboxes = game.add.group();
  hitboxes.enableBody = true;  
  hitbox1 = hitboxes.create(-100,-30,null);
  hitbox1.body.setSize(65,70,0,-30);

  dude.addChild(hitboxes);   // this time the child is an isoSprite because I used create and create is used to add sprites
 

 

asdadar.PNG

I found this thread here: http://www.html5gamedevs.com/topic/9301-phaserpluginisometricisosprite-add-child-does-not-work/

hmm and what if I used hitboxes with no depth, could that affect gamplay in the future?

What do you think @Milton?

 

Share this post


Link to post
Share on other sites
50 minutes ago, Milton said:

Hmm. I think you found some interesting bugs :) Too bad Lewster isn't around.
I could fix this for you if you really want, but I'll give it a few days, just to see if @lewster32 comes back and picks it up...

Well I am not in a hurry. I believe I have so many other things to learn :P. Without getting into reasons or personal stuff, do you know if lewster plans to continue backing up the isometric plugin? I just ask this to know if using the plugin will be worth for the future time situation... 

Share this post


Link to post
Share on other sites

Since Phaser has basically cornered the JS gamedev market, it would be wise for @rich and @lewster32 to develop the plugin. Basic Tiled support is easy, *without* collision that is... Adding Isometric TileMap support to Phaser is *very* much work, but I think it should be done.

The real problem with 2D Isometric is depth sorting. You (and most people) haven't got that far yet, but as soon as you start using Z (height), you're in for a world of pain.
That's why I would advice to look at 3D engines (which also give you the option of rotation/dynamic lighting).

Share this post


Link to post
Share on other sites
1 hour ago, Milton said:

Since Phaser has basically cornered the JS gamedev market, it would be wise for @rich and @lewster32 to develop the plugin. Basic Tiled support is easy, *without* collision that is... Adding Isometric TileMap support to Phaser is *very* much work, but I think it should be done.

The real problem with 2D Isometric is depth sorting. You (and most people) haven't got that far yet, but as soon as you start using Z (height), you're in for a world of pain.
That's why I would advice to look at 3D engines (which also give you the option of rotation/dynamic lighting).

Yeah I understand what you mean... You already told me that before some days ago when I asked if three.js could would bring advantages. Probably I will start using it  mainly since depth sorting seems to be "hated" by game devs. Does three.js have a supportive community like phaser's? I mean until now fortunately, with Phaser I always got the help I needed (mostly you ;) )

 

EDIT: Also, I just saw "babylon.js". Seems to be good too. Have you ever used it?

Share this post


Link to post
Share on other sites

The Babylon community is much better than that of Three.js (which doesn't really exist). If you are going with JS or TypeScript, I would go with Babylon.
Since I use Haxe, I like Three.js, because Babylon for Haxe has problems with mixing 2D/3D (for now).

Share this post


Link to post
Share on other sites
55 minutes ago, Milton said:

The Babylon community is much better than that of Three.js (which doesn't really exist). If you are going with JS or TypeScript, I would go with Babylon.
Since I use Haxe, I like Three.js, because Babylon for Haxe has problems with mixing 2D/3D (for now).

Oh ok. Got it. Thank you once again.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.