Results 1 to 3 of 3

Thread: Mouse Control issue

  1. #1

    Mouse Control issue

    First of all, thanks everyone for help. My group somehow finished creating half-*****'d game past weekend for TOJAM event... boy that was hard.

    We used copypixel, some spritemap to animate and 0 movie clips. Pure AS3, more or less.

    We actually tried to solve this one problem for half a day and resorted to switching the player control to keyboard from mouse. (that was done in less than 1 hour... I wish we made the decision instead of wasting precious 7 hours of 48 hour competition... we could have done so much...sigh)

    Anyway, I am working on it again and I am pretty happy with controls since I think I can easily port this for Wii later.

    But the mouse control issue still annoys me. Here is the detail:

    There are many little characters you can grab. When the user graps one of them and try to move them from one end of a room to the other, the character is pushed back if there is anyone on his/her path.

    So we used hitTest to determine if there are anyone... then used rad/arctan formula to calculate the angle and pushed the character back.

    We also found out if the user is still pressing down (dragging), then there would be increased offset (since the character is now bounced back even though user still controls him)... so I coded to lose the control of the character when that offset is beyond certain limit.

    So far so good... but I noticed the characters shake a lot due to constantly being pushed back instead of being 'stuck' at certain distance and staying there.

    I believe that's because mouse is very sensitive and we are calculating by x,y coordinate, which changes ever so slightly.

    Even the arctan funtion didn't seem to work... as the character wasn't bounced back at each angle but on 45 degrees or -135 degrees only...

    Anyway, it seems other people had similar issues of mouse controlled charcter hitTest and collisionHandling same sized (small) objects.

    If anyone has an advice or solution, please let me know. If I thoroughly confused everyone, I will see if I can create a simple code to showcase.

  2. #2
    hmmph...you have a nice problem there, and i cant help much without seeing the code. But since you say there are a lot of objects to check against, i suggest you do the opposite, check the character on mouse for collision, from the other characters, and use distance checking before doing hitTest. This way, the character on the mouse wont jump, unless some other character sees a collision and tells it to jump...
    MY BLOG

    I need a SPRITER who can do pixel arts for an arcade fighter project. If you can help out, please pm me.
    I also need someone who can write simple xml files.


  3. #3
    Quote Originally Posted by bluemagica View Post
    hmmph...you have a nice problem there, and i cant help much without seeing the code. But since you say there are a lot of objects to check against, i suggest you do the opposite, check the character on mouse for collision, from the other characters, and use distance checking before doing hitTest. This way, the character on the mouse wont jump, unless some other character sees a collision and tells it to jump...
    That's pretty much the direction I am going now, though with keyboard.

    I will definitely create a demo so I can show my dilemma.

    For now, for each update, I check the player's direction. Then I run though where the player will end up and do the hitTest.

    If no obstruction, then move otherwise no update for the player.

    Of course, my code isn't work as I intended so I will probably need to see what I am doing wrong and even write it down instead of hacking it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012