Sign in to follow this  
gamify

vector2D to isometric

Recommended Posts

 this.patrol_addPoint( new me.Vector2d(100, 100));
          this.patrol_addPoint( new me.Vector2d(200, 100));
            this.patrol_addPoint( new me.Vector2d(200, 200));
            this.patrol_addPoint( new me.Vector2d(100, 200));

how can i convert moment of 2D to 'isometric sprite animation' movement .Please can anyone help??

Share this post


Link to post
Share on other sites

i am trying to move my sprite in isometric way but it is taking the orthogonal way 

 

i tried that is throwing error 

 me.Vector2d.toIso is not a constructor

 

tried using example : 

Add a point which a patrol has to go through

this.patrol_addPoint( new me.Vector2d(100, 100));
this.patrol_addPoint( new me.Vector2d(200, 100));
this.patrol_addPoint( new me.Vector2d(200, 200));
this.patrol_addPoint( new me.Vector2d(100, 200));

Set direction and looping

this.patrol_setInfinite(true) 
this.patrol_setReverse(true)

Start the patrol

this.patrol_walk();

For more detail see demo.

https://github.com/Kibo/melonjs-cookbook/tree/master/cookbook/patrol

 

 

Share this post


Link to post
Share on other sites

Movement will only follow the path that you define.

You should be able to get some visualization very easily by drawing the path with the canvas lineTo() and stroke() methods. When your path is drawn the way you expect it, then getting the entity to follow that path is a piece of cake.

Share this post


Link to post
Share on other sites

this.patrol_addPoint( new me.Vector2d(100, 100)); it should take isometric x=100,y=100 right it is going outside isometric i thought sprite is bounding outside the game

Share this post


Link to post
Share on other sites

even after giving pos using me.input.pointer.pos.x & me.input.pointer.pos.y it is taking as diff position as orthogonal and i am sure it is taking orthogonal because example i have taken of orthogonal and converting to isometric

Explanation :

 instead of 100 passing some points retrieved from me.input.pos.x 

 this.patrol_addPoint( new me.Vector2d(100, 100));

instead of moving on me.input.pos.x it is taking orthogonal (x,y) position

 

Share this post


Link to post
Share on other sites

Did you completely miss obiot's message where he provided the answer to that question?

FWIW, there are no strict boundaries for sprites or entities. This is how we're able to allow the spaceman in the platformer example to fall into pits and restart the level; if the entity was clipped to the world boundaries, he wouldn't be able to fall into pits and it would be very weird. That's not to say you can't clip entities; melonJS just doesn't do that for you.

Share this post


Link to post
Share on other sites

okay thank you and i used .Iso()  function yes moving in isometric but only movement position was (0,0) orthogonal instead of isometric(0,0) position .

So i need isometric map cordinates(0,0) ???

Share this post


Link to post
Share on other sites

i tried giving collision border but it is not moving outside the world because of the collision wall but its stopped and moving in standing position

Share this post


Link to post
Share on other sites

Movement will only follow the path that you define.

You should be able to get some visualization very easily by drawing the path with the canvas lineTo() and stroke() methods. When your path is drawn the way you expect it, then getting the entity to follow that path is a piece of cake. 

can you suggest me example to do this 

Share this post


Link to post
Share on other sites

Not sure of the answer as I have yet to work on an isometric game, but for debugging it, I would see how the coordinates turn out for your addPoint calls, and compare them against the ones of the blue tile. It might be worth noting, that one needs to generally convert screen coordinates to world coordinates. http://melonjs.github.io/melonJS/docs/me.Viewport.html#localToWorld

Share this post


Link to post
Share on other sites

@gamify did you try drawing the path, and using the dev console to check what is going on ? At some point you have to experiment by yourself, and here we are just talking about drawing a line, and not some super advance game algorithm or stuff.

So either from the melonJS renderer :

https://melonjs.github.io/melonJS/docs/me.CanvasRenderer.html

or just using the standard canvas API :

https://www.w3schools.com/tags/canvas_lineto.asp

 

 

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.