Results 1 to 1 of 1
- 11-07-2012, 12:44 PM #1
Senior Member
- Join Date
- May 2012
- Posts
- 170
- Rep Power
- 1
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
And the myEq class: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 }
UPDATE 1: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); } }
The equipment (myEq) is lagging only when I flip it horizontally, when it's the original size and scale it's not lagging.
the part that there is -72 flips the image horizontally, and the lag comes in..Java Code:g.drawImage(standing1,(int) (Window.charX+ 72)-(int)Window.camSmootherX ,(int) Window.charY-((int) Window.camSmootherY)-3,-72,Photo.standing1.getHeight(),null);
Last edited by Lionlev; 11-07-2012 at 01:48 PM.
WARNING I am Russian so it's possible that I wont understand you correctly...
Similar Threads
-
A problem in capturing video with JMF
By Bahramudin in forum Advanced JavaReplies: 0Last Post: 08-20-2012, 04:07 PM -
Problem about uesr defined class: want explanation
By abhinav435 in forum New To JavaReplies: 3Last Post: 03-23-2012, 07:32 PM -
Explanation of problem and/or alternative solution
By USMCstitch in forum New To JavaReplies: 5Last Post: 04-19-2011, 03:21 AM -
Video Problem
By dewitrydan in forum New To JavaReplies: 0Last Post: 09-06-2010, 12:34 PM -
Animation Delay - Thread problem
By wererabit in forum Advanced JavaReplies: 3Last Post: 04-10-2009, 10:35 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks