Results 1 to 3 of 3
  1. #1
    Blagojee is offline Member
    Join Date
    Apr 2017
    Posts
    1
    Rep Power
    0

    Default Spawning object on mouse coords

    I have a problem with my program, it has lagging in positioning an object on mouse x and y
    here is a example of itSpawning object on mouse coords-capture.png
    Here is Algorithm that I used:
    Java Code:
        x.px = normalize((mouse.x - Gdx.graphics.getWidth()/2 + camera.viewportWidth/2) * c.AU);
        x.py = normalize((mouse.y + Gdx.graphics.getHeight()/2 - camera.viewportHeight/2) * c.AU);
    here is full code: https://pastebin.com/VgGVsSFj

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Spawning object on mouse coords

    Can you make a small, complete program that compiles, executes and shows the problem?
    Post it here wrapped in code tags.

    A suggestion: Your debug display should show the values of x and y in addition to the names.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Spawning object on mouse coords

    Ugh! The use of Gdx.graphics tends to make me think this isn't from the Java API.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Object follow mouse
    By Joey0412 in forum New To Java
    Replies: 19
    Last Post: 04-22-2012, 04:39 PM
  2. Help with mouse moving object and colisions
    By macwadu in forum AWT / Swing
    Replies: 12
    Last Post: 07-01-2010, 11:18 PM
  3. Mouse Listener for mouse floating over object?
    By Krooger in forum AWT / Swing
    Replies: 1
    Last Post: 11-18-2009, 04:34 AM
  4. placing JButtons with x and y coords (possible?)
    By v1nsai in forum New To Java
    Replies: 4
    Last Post: 08-18-2009, 06:21 AM
  5. change object color on mouse click
    By gotenks05 in forum Java Applets
    Replies: 1
    Last Post: 04-05-2009, 07:14 PM

Tags for this Thread

Posting Permissions

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