开发者

Flash AS3: isometric grid movement

开发者 https://www.devze.com 2023-02-15 01:38 出处:网络
Really desperate help needed for this Flash AS3 question. I am currently creating a game similar to cafe world, farmville etc (social game). Would like to know how could i make an object move in an is

Really desperate help needed for this Flash AS3 question. I am currently creating a game similar to cafe world, farmville etc (social game). Would like to know how could i make an object move in an isometric direction when my mouse move. For example, when I want to build a house, i click on the house build button, and when my mouse move, I want my house object (stored in the library) to be move together with my mouse in an isometric direction. To give you all a better impression of the solution i am looking for, click on this link for a sketch: http://www.flickr.com/photos/58743938@N07/5497636770/

So i want something like only when my mouse move 20 units more than the original mouse position, then my house item should move to the next grid.

Do clarify with me if there's anything that is unclear. Tha开发者_Go百科nks a lot! :)


You might like to explore as3isolib... http://code.google.com/p/as3isolib/

There's a nice introduction here... http://www.gotoandlearn.com/play.php?id=136

What you are looking at is probably something like this though...

house.x = Math.floor(this.mouseX/SQUARE_SIZE)*SQUARE_SIZE;
house.y = Math.floor(this.mouseY/SQUARE_SIZE)*SQUARE_SIZE;

You might need to do some globalToLocal or vice versa for the mouse position, plus an offset for the grid etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号