Results 1 to 1 of 1
  1. #1
    Lionlev is offline Senior Member
    Join Date
    May 2012
    Posts
    172
    Rep Power
    3

    Red face Delay between 2 same timings problem (Video of explanation of the problem inside)

    Basically I've got 2 graphics classes, one is the override (takes other graphics classes and paints them) and other is just a class that creates graphics
    names:
    overrided graphics class: Photo
    Graphics class: myQe

    On the main class there is a thread that repaints the graphics every 1000/60 milliseconds (60 fps).
    Photo class also paints the character at it's x and y coordinates, the coordinates can change when I press the arrow keys (so the character can move)
    That works fine
    But then I draw the myEq RIGHT AFTER the draw character and at the same coordinates as the character.
    But the problem is that it got a little bit of delay between two graphics and it looks like myEq is following the character...

    Check this video that will show you the problem:




    So here is the part of the code of the Photo class that located in paintComponent method
    Java Code:
    	if(direction1 == 1){
    					g.drawImage(standing1,(int) Window.charX-(int)Window.camSmootherX + 72,(int) Window.charY-((int) Window.camSmootherY)-3,-72*direction1,standing1.getHeight(),null);//Paints the main character
    					myeq.renderMe(g);//Paints the myEq (It's a chest equipment graphic)
    				} else {
    					g.drawImage(standing1,(int) Window.charX-(int)Window.camSmootherX,(int) Window.charY-((int) Window.camSmootherY)-3,-72*direction1,standing1.getHeight(),null);//Paints the main character only turn him to the other side
    					myeq.renderMe2(g);//Paints the myEq, same here
    				}
    And the myEq class:
    Java Code:
    public void renderMe(Graphics g){
    		if(localEq1!=0){
    			g.drawImage(standing1,(int) (Window.charX+ 72)-(int)Window.camSmootherX ,(int) Window.charY-((int) Window.camSmootherY)-3,-72,Photo.standing1.getHeight(),null);//36 default
    		}
    		if(localEq2!=0)	{
    			g.drawImage(standing2,(int) (Window.charX+ 72)-(int)Window.camSmootherX ,(int) Window.charY-((int) Window.camSmootherY)-3,-72,Photo.standing1.getHeight(),null);
    		}
    	}
    	public void renderMe2(Graphics g){
    		if(localEq1!=0){
    			g.drawImage(standing1,(int) Window.charX-(int)Window.camSmootherX,(int) Window.charY-((int) Window.camSmootherY)-3,-72*Photo.direction1,standing1.getHeight(),null);
    		}
    		if(localEq2!=0){
    			g.drawImage(standing2,(int) Window.charX-(int)Window.camSmootherX,(int) Window.charY-((int) Window.camSmootherY)-3,-72*Photo.direction1,standing1.getHeight(),null);
    		}
    	}
    UPDATE 1:
    The equipment (myEq) is lagging only when I flip it horizontally, when it's the original size and scale it's not lagging.
    Java Code:
    g.drawImage(standing1,(int) (Window.charX+ 72)-(int)Window.camSmootherX ,(int) Window.charY-((int) Window.camSmootherY)-3,-72,Photo.standing1.getHeight(),null);
    the part that there is -72 flips the image horizontally, and the lag comes in..
    Last edited by Lionlev; 11-07-2012 at 02:48 PM.
    WARNING I am Russian so it's possible that I wont understand you correctly...

Similar Threads

  1. A problem in capturing video with JMF
    By Bahramudin in forum Advanced Java
    Replies: 0
    Last Post: 08-20-2012, 05:07 PM
  2. Problem about uesr defined class: want explanation
    By abhinav435 in forum New To Java
    Replies: 3
    Last Post: 03-23-2012, 08:32 PM
  3. Explanation of problem and/or alternative solution
    By USMCstitch in forum New To Java
    Replies: 5
    Last Post: 04-19-2011, 04:21 AM
  4. Video Problem
    By dewitrydan in forum New To Java
    Replies: 0
    Last Post: 09-06-2010, 01:34 PM
  5. Animation Delay - Thread problem
    By wererabit in forum Advanced Java
    Replies: 3
    Last Post: 04-10-2009, 11:35 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
  •