Move container sprite according to mouse movement

Hi All,
Currently I'm developing a game where there is a object which follows mouse. Also there are other objects and a map on the screen.I want all of background content(whole map and other objects) to move when user moves mouse left or right. That is, if user moves mouse on right side then all content(except object which moves as per mouse) should move left side so that user can see remaining part of map on the right side.
As of now I have created new Container sprite in which I have added all of my objects and map. So when user moves the mouse right, I move the container sprite to left so it looks all stuff moves to left. Code looks like as below
var pt:Point = new Point(character.x, character.y);
pt = dori.localToGlobal(pt);
if (pt.x > (stage.width * 0.5))
                    container.x -= 5;
Structure of project is such that, I add Container directly to stage. and this container contains everything like map, character and other objects.
Now issue is that as soon as mouse goes beyond middle of stage...it creates distance between mouse location and character..!! I mean it does move according to mouse but some distance get created between mouse and character. and this distance keeps increasing as I continue to move mouse away from center of stage!!
I'm really stuck with this issue. Please someone help with this. I hope I have explained this well. Let me know if you need more info but please help.

No see......I dont want ease in n all....and character following the mouse logic is working fine if I dont use above linear interpolation to move the container mc.....
but I do want to move container mc as well so I will have to use what you gave to move the all background objects when user moves mouse....
so Again to clarify, in the game when user moves mouse the character should follow and at the same time bakckground objects which are in container mc should move opposite to mouse movement so that remainng mape gets visible to the user....
just now when I was debuggin the linear interpolation logic...I got to know that there something I need to change in it...because accroding to that logic...let say for example
stageWidth is 480
maze.width is 551
then x1 will be  480
y1 will be -71
x2 will be 0 and
y2 will be 0
so m = (y1 - y2) / (x1 - x2) = -71 - 0 / 480 - 0
m = -0.147
b = y1 - m * x1 = -71 - (-0.147 * 480) = 0
so on each enter frame when mouseX wil be multiplied with m....it will create lag in moving container(character is in container as well!
bcoz
container.x = m * stageRef.mouseX + b;
so I'm confused!!
where do u think shall correction be made??

Similar Messages

  • Move image according to mouse movement

    Hello
    I am beuilding a game similer to the classic pong game.
    I trying the build it a way that the user will control it "player" with the mouse.
    The "player" only have to move in up or down
    I cant make the  "Player" move exactly as the mouse
    Does anyone have an idea how to make it work?
    Thanks
    Amir

    Perfect: that was it. Many thanks..
    jwc

  • Moving mouse moves the entire screen

    When I move the mouse the entire screen moves in the direction the mouse moves. Tried different mouse, keyboard, restarting. Nothing works. The computer still works fine, it's just the moving screen won't stop

    Open the Universal Access pane of System Preferences, click on the Seeing tab, and turn off Zoom.
    (31635)

  • Follow sprite when the mouse is down, but randomly move when mouse is up?

    I have a sprite that has a Random Movement behavior.
    While the mouse is down, I want it to stop this behavior and initialize a Follow Sprite behavior instead.
    When the mouse is lifted, I want to stop the Follow Sprite behavior and reset/restart the Random Movement behavior.
    Openspark helped me out with a different version of a very similar behavior a long while back, which worked. It switched between Random Movement and Draggable. I tried to edit the code so that it would apply to Follow Sprite instead of Draggable, but it isn't working the way I thought it would.
    The order of behaviors on my sprite is as such:
    followSprite (Follow Sprite)
    moveToward (The behavior described above)
    randomMove (Random Movement)
    turnTowardsMouse (sprite faces mouse when it is clicked)
    Face Destination (if not facing mouse, sprite faces toward the randomized endpoints generated by randomMove)
    This is the moveToward behavior - the middleman that's supposed to be swapping between the two:
    property pSprite
    property pTouching
    on beginSprite(me)
      pSprite = sprite(me.spriteNum)
    end beginSprite
    on mouseDown(me)
      -- Overrule the Random Movement and Rotation behavior until the mouse
      -- is released. See the on prepareFrame() handler for the effect.
      pTouching = TRUE
    end mouseDown
    on prepareFrame(me)
      if pTouching then
        -- Block the event from reaching the Random Movement and Rotation
        -- behavior, so that only the Draggable behavior will work.
        if the mouseDown then
          stopEvent
        else
          -- The user has released the mouse.
          -- Start a new movement in the Random Movement and Rotation behavior.
          pSprite.pPath = VOID
          sendSprite(pSprite, #mNewPath)
          pSprite.pRotate = VOID
          sendSprite(pSprite, #mNewRotation)
          pTouching = 0
        end if
      end if
    end prepareFrame
    Can anyone help me figure this out?
    If you want to imagine a visual, it's essentially a touchscreen fish tank. Fish swim around randomly, but when someone is touching the screen, they approach the point of contact (which is defined by a tiny invisible sprite centered on the cursor).
    Once again, thank you so much to anyone who can help me out. This is part of a capstone undergraduate art project I am doing - and I am far more experienced in making the visuals than I am in coding. I am having to mostly tackle Lingo on my own. Any coding help I've received will be recognized (with permission) on my artist website as well as a thesis paper I am writing that will be published in May.

    As first steps at troubleshooting you could try an SMC reset and a PRAM reset:
    SMC Reset
    Shut down the computer.
    Unplug the computer’s power cord and disconnect peripherals.
    Press and hold the power button for 5 seconds.
    Release the power button.
    Attach the computers power cable.
    Press the power button to turn on the computer.
    Reset PRAM
    Shut down the computer.
    Locate the following keys on the keyboard: Command, Option, P and R.
    You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys. You must press this key combination before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time.
    Release the keys.
    If that doesn't help, what OS are you running? Depending on the OS (Lion/Snow Leopard) will help determine the next step.

  • Slider moves on mouse movements

    Hi,
    I know how to make slider to move to one direction when mouse
    in over center of the movie.But how can I make this: I move mouse
    in one direction (it doesnt matter where it is) and the slider
    moves to other. So, in a few words. Mouse moves in one direction,
    the movie moves in other.Any tutorial?
    THX

    You might find code if you search Google, but the basics of zooming into a section of soomething like a map involves having the map inside a container that is centered in the viewport and scaling the container instead of the map for the zooming.  That allows you to move the map around and zoom in while having the map in differrent sections.  The container stays celetered since that is where it needs to be to have the zoom stay in the center.
    As far as moving the map via moving the mouse to the edges, that can be accomplsihed either by having unseen objects with mouseover lsiteners at the edges that you use to trigger movement of the map, or you establish numeric boundaries that you constantly monitor to detrmine which way to move the map if at all.  The mouseover approach is probably simpler to manage.

  • Effects search box must be dealt carefully - if the mouse moves slightly then fcpx behaves as shortcuts

    Hi..
    when we search for some effect using the search box, under the effects window, or may be title or any other window... we must be very careful that the mouse never moves after clicking (for the cursor) in the effects search box (at the bottom right)...
    if the mouse moves slightly away from the search box then when we type, fcpx behaves as shortcuts and does not type inside the box... which is very frustrating...it changes so many things according to the shortcuts instead of the text inside the search option...
    Hope all this is corrected in updates. It would be great if someone can pass this msg to apple development team. Thank you !!
    Regards,
    Arun Kanth

    My skimmer is enabled. When I click in the box, it is ringed in blue.
    I can move the pointer anywhere in the screen and type in the box that remains active.

  • Listening for mouse move from JFrame?

    Hi
    I'm facing a problem when I wanted to use the JFrame's method: addMouseListener( ) to listening for the mouse whether it moves from a JFrame.
    In my code the JFrame containts three components:
    public class NFrame extends JFrame{
    JPanel contentPane = (JPanel)super.getContentPane();
    contentPane.setLayout(new BorderLayout());
    JMenuBar jMenubar=new jMenuBar();
    JTabbedPane jTabPane=new JTabbedPane(JTabbedPane.LEFT,JTabbedPane.WRAP_TAB_LAYOUT);
    JPanel bottonPane=new JPanel();
    contentPane.add(jMenuBar,BorderLayout.NORTH);
    contentPane.add(jTabPane,BorderLayout.CENTER);
    contentPane.add(bottomPane,BorderLayout.SOUTH);
    addMouseListener(new MouseAdapter() {
    public void mouseExited(MouseEvent e) {
    System.out.println("Mouse remove from JFrame");
    Because the JTabbedPane has a default mouse Listener, thus the mouse event is caught by jTabPane and the application does not print the above message when mouse moves from jTabPane.
    Could anybody give me some hints?
    Thanks!

    In this case there should probably not be a sleep()
    at all. You might want to do that sort of thing when
    you have a new thread whose job is to have
    non-GUI-related functionality (like a clock ticking,
    or sprites moving in a game independently). For
    standard GUI interaction, the GUI thread takes care
    of things and you don't need to wait at all. You're
    already waiting, basically.Oh, I see! The OP is doing quite useless things!
    I didn't see such f**lish things in the past!
    The OP should learn the basics for GUI and event mechanism.
    http://java.sun.com/docs/books/tutorial/uiswing/

  • Mimicking mouse move event

    Hi,
    I'm using flex through a plugin, and not though a browser (like most people do). For some strange reason my flex SWF doesn't receives mouse move events. I can get the mouse move events in the application that contains the SWF, and I can tell the SWF that the events has occured, using the externalInterface API.
    Once I received a call that indicates a new mouse position, I want to mimick it as a normal mouse move event. Any ideas on a simple way to do this?
    thanks in advance,
    Vince

    If you have the stage coordinates of the mouse, you can get pretty far by calling getObjectsUnderPoint and dispatching a MouseEvent from the last element in the array (converting the stage coordinates to local).
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Mouse Movement over desktop

    hi guys, i am working on a network project, my aim is to move the mouse at one side, get its coordinates, send them to the other side, and let the mouse move according to this.. i am working over desktop not on a frame. so i have succeeded moving the mouse and sending the coordinates. on the receiver side i cant get the mouse to move according to the coordinates it is receiving!! can anyone help me! thank you

    hi guys, i am working on a network project, my aim is
    to move the mouse at one side, get its coordinates,
    send them to the other side, and let the mouse move
    according to this.. i am working over desktop not on
    a frame. so i have succeeded moving the mouse and
    sending the coordinates. on the receiver side i cant
    get the mouse to move according to the coordinates it
    is receiving!! can anyone help me! thank youAre you moving the mouse programmatically?

  • Mouse Move Operation in 10g

    Hi Guys,
    We are doing migration of Forms from Oracle 6i to 10g.
    In 6i One form contain Mouse Move Trigger.
    Let me know,Whether Mouse Move Option will work in Oracle 10g ?
    Otherwise,How to handle this type of trigger in Form.?
    If it work fine then,Tel me the Solution how to use this?
    Thanks,
    Gany

    Hello,
    The Oracle Forms OTN Forum is here : Forms
    Regards

  • CP5: Change mouse movements in recorded slides

    Once again I have recorded a software demo with my recording settings set to show mouse movement. Before that I split the 880 resulting slides into projects of 100 slides each: is there a way to set mouse movement options to all the slides, specially to set the option "straight pointer path"  for all mice in all slides?

    Hi Rick,
    thank you for the information. With this changing the pointer path works fine. So my main concern has been solved.
    But there are still other options that I would like to handle more efficently like switching "Reduce Speed Before Click" on / off.
    Then I would like to show user defined Mouse Clicks dependent on Single oder Double Click Mouse Click Sound and / or dependent on left or right mouse click. For example: Several slides contain these mouse options for a right click from recording (whether it is left or right can de determined by the text caption):
    In all these slides I want to change the mouse options to:
    Doing all these changes manually is very time consuming. And I wonder, whether there might be a better way to perform that task.

  • Mouse movement always added

    I have unchecked the box that says record mouse movement, and
    yet Captivate is always adding the mouse into my newly recorded
    slides, forcing me to delete them.
    Is there any way to change this behavior?

    Hi RedScare
    Are you talking about generically opening Captivate and
    recording an entirely new project? Or are you instead talking about
    adding additional slides to an existing project?
    Either way, I would think Captivate should respect any
    settings in place and give you what you want. So it's possible you
    may be seeing a new issue that needs to be reported to the
    development team.
    As a workaround, if it's giving you mouse movement and you
    really don't want it, you may easily turn the mouse off for a group
    of slides by selecting all the slides containing the mouse
    movement, then clicking Slide > Mouse > Show Mouse to turn it
    off for the selection. That would save having to change it
    individually on many slides.
    How did this project begin life? Was it started in perhaps
    Captivate 1 or 2 and later converted to 3? I know once in a while
    we see issues from those actions.
    Cheers... Rick

  • I just created a new profile/user on my MacBook Pro. My pointer/mouse. It works fine in my older user profile, but when I go to the new profile my mac will not respond to clicks. Mouse moves but will not click. Already tried restarting and the pram zap.

    I just created a new profile/user on my MacBook Pro. My pointer/mouse on my trackpad. It works fine in my older user profile, but when I go to the new profile my mac will not respond to clicks. The Mouse moves but will not click. Already tried restarting and the pram zap. The problem starts when I log out of my main profile. I get to the login screen and my laptop stops responding to clicks. When I manage to make my way back to my main profile the mouse works perfectly.  Should I just delete the new profile and try again?

    If the modem is also a router, either use the modem in bridge and run pppoe client on the TC.. that is assuming ADSL or similar eg vdsl. If it is cable service.. and the modem is a router, then bridge the TC.. go to internet page and select connect by ethernet and below that set connection sharing to bridge.
    Please tell us more about the modem if the above gives you issues.

  • "The movie contains an incorrect time value" error - saving a trimmed video

    I am attempting to trim a video shot on my Samsung CL65. The video was shot in High Quality HD 1280 x 720. I open the video in QuickTime and then use the Trim command to remove the last part of the video and then close it to Save it. When I save it I get the following error: "The document SAM_0306.MP4 could not be saved as "SAM_0306". The movie contains an incorrect time value." I think this has to do with an encoding error in the original file or in the trimmed file but I have no idea how to get around it.
    Any ideas?

    This info probably won't help with your problem, but it's information for others who get this error.
    It's probably the software that made the MP4. ffmpegX, for example, and the mencoder program inside it, do this with every H264 encoding when the video is longer than 1 hour. Time codes are correct up to 1 hour, then the seconds value gets wacky (3600 is added to it). Quicktime won't save a movie with a time code like 1:20:3623.120 (although it will correctly display 1:20:23 in the player).
    Apple used to offer quicktime scripts that would allow you to see what the time code in a stream really looked like. Applescript appears to have officially and quietly gone missing, though, and those scripts are no longer available online as far as I can tell. There were some really handy other scripts that would allow you to view all sorts of movie properties and manipulate tracks (great for syncing poorly synced sound, for example), but time code problems like the above would invariably mean the movie couldn't be saved.

  • After sleep, retina MacBook Pro (Mid 2014) does not recognize usb connected mouse movement

    After sleep, retina MacBook Pro (Mid 2014, on 10.9.4) does not recognize usb connected mouse movement. I have tried a generic usb mouse and my Razer Deathadder usb mouse. Both mice work before sleep; but after sleep, the computer no longer recognizes mouse movement while still recognizing the mouse buttons when pressed. Any idea why this is occurring?

    Hello, chocotac0.  
    Thank you for visiting Apple Support Communities.
    Here are some troubleshooting steps that I would recommend when experiencing this issue.
    OS X Mavericks: Reset your computer’s PRAM
    http://support.apple.com/kb/ph14222
    Intel-based Macs: Resetting the System Management Controller (SMC)
    http://support.apple.com/kb/ht3964
    OS X Mavericks: If a USB device isn’t working
    http://support.apple.com/kb/PH13876
    Cheers,
    Jason H.

Maybe you are looking for

  • View pdf files in safari

    When I click a link in Safari that goes to a PDF document All I get is a blank webpage. Why won't Safari display a PDF?

  • How do I NOT open .PDF files in Preview?

    Hi Everybody, I am sure that this is a downright goofy question, but I have looked through the forums and can't seem to find out how to open .pdf files in Acrobat by default instead of Preview. It's probably right in front of my nose, but I'm not fin

  • How do you filter GW Messenger User Properties

    I'm trying to filter or view the users in console one with GW Messenger custom contacts is there a way and if so how would I go about that

  • Working with footage exported from After Effects

    Hello! I'm using after effects because i'm more familiar with it and i don't want to relearn a visual effects software right now, so hopefully some of you might be familiar with it. I compiled my video using a NTSC DV Widescreen composition. I export

  • Changing WiFi Passwords in Windows 8

    Here we go... I was able to set up wifi access at work, but when I get home, I can't connect to the router.  My laptop gets the signal, but I don't know how to change the password so that I can actually get on the net.  I'm sure this is a simple issu