User Tag List

Results 1 to 8 of 8

Thread: Isometric mouse following

  1. #1
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2007
    Location
    Poland
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Isometric mouse following

    Hello.
    I'm trying to solve one thing for last three days... If I create normal grid like this:


    There is no problem to make item following mouse on the grid, I just set position of object to position mouse / 92 * 92 and it works perfectly.

    But problem appears on the isometric grid:


    What is the "algorithm" of object's positions to follow mouse on this isometric grid?

    I was trying to use extensions, but there are limits of grid, so I would like to make it without any grid extensions, by myself.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Ryan's Avatar
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    1,279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Isometric mouse following

    Isometric standards usually use a 30 degree angle grid, but for simplicity I will use a 3:2 ratio (which provides angles of 33.7 degrees).

    Each square is squashed vertically by 33.3%. Ie. If it's 92 pixels wide, it's 61.3 pixels high. I'd recommend switching to something that won't cause decimal points, such as 90 pixels wide and 60 pixels high.

    Check your isometric grid for the 3:2 ratio before starting, otherwise you could get all sorts of problems further down the line.

    Now if you snap to X to X/90*90 and Y/60*60 you'll get much better snapping. There is an issue though, every second row is offsetted 50% of the width horizontally from the previous row and 50% of the height vertically. You'll have to work this into your snapping calculation to get proper snapping.

    For this I'd recommend the MOD function (I hope your familiar with it, otherwise google is your friend):

    Code:
    If (Y/30) MOD 2 = 0
    - Set X Offset = 0
    If (Y/30) MOD 2 = 1
    - Set X Offset = 45
    
    Always
    - Set X to (X/90*90) + X Offset
    - Set Y to Y/30*30
    Or to make it all one equation

    Code:
    Always
    - Set X to (X/90*90) + (((Y/30) MOD 2)*45)
    - Set Y to Y/30*30
    This isn't going to be perfect as it may not snap perfectly your mouse position, however it's very close. you'll need to experiment with adding and subtracting offsets to the MouseX position to get pixel perfect grid snapping.

    There's also an issue with area detection, as this draws approximate detection boxes around your isometric grid. So your mouse position isn't going to follow the angled lines.

    Proposed fixes:

    a) Convert your X and Y mouse position into isometric values using trigonometry functions.

    - or -

    b) Lay out isometric detector active objects and using fine collision detection have:
    Code:
    When mouse is overlapping object
    - Set position of highlight to position of isometric grid object.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Ryan's Avatar
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    1,279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Isometric mouse following

    Actually I just built an example to try the box method and it's a poor method, I'd suggest going with a grid of actives.

    Perhaps someone else can explain the trigonometry method, I haven't practised it myself and I don't really have the time to experiment with it.

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Ryan's Avatar
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    1,279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Isometric mouse following

    *Bump*

    Grim did you find your answer?

    I can build you a trigonometry example over the weekend if you still need help.

  5. #5
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2007
    Location
    Poland
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Isometric mouse following

    Wooops, I'm sorry that I didn't thank you when I read your post for the first time, I just forgot to do this. Yes, your post helped me a lot, thank you.

  6. #6
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Isometric mouse following

    Are you making a diamond shape isometric map, or are you making a staggered isometric grid?
    (diamond means a square map rotated on an angle, so the corners of the map are empty, while staggered is a square map with isometric tiles. Google them for more info)
    The maths for both are different.

    There is an isogrid2 object which will handle diamond iso grid for you no problem, but if you want a staggered iso grid you need to work out maths yourself which you can easily find on google.
    I had an extension I was working on which could do both types of maps as well as hex maps, but i never released it and dunno if I ever will.

  7. #7
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2007
    Location
    Poland
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Isometric mouse following

    Well, I'm trying to make a map editor with staggered isometric grid. Thank you for replay, I'll also check on google for some algorithms.

  8. #8
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Isometric mouse following

    Ok, well there is no extension to handle the maths for you. Maybe one day I will release my extension i started but I doubt it.
    My extension took care of all grid maths and also handled drawing the map, scrolling everything.

Similar Threads

  1. isometric help
    By strangely in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 22nd December 2008, 11:00 AM
  2. Mouse Movement prevents mouse click event?
    By Tuna in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 2nd March 2008, 02:52 AM
  3. Isometric
    By robi in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 31st December 2007, 11:49 AM
  4. Mouse click events runs faster when mouse moves
    By chrilley in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 2nd February 2007, 02:54 PM
  5. Mouse click doesnt work when Mouse movement used
    By Blizna in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 21st September 2006, 02:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •