for this purpose you should use synchronized function for synchronized animation and sound with
your events occurred when key pressing.for Synchronize any functions you should use synchronized word before you functions this function is used for play mp3 sound
public synchronized void playmusic(String file)
{
if(sound==0)
try
{
Player p = Manager.createPlayer(file);
p.setLoopCount(5);
p.start();
}
catch(IOException e)
{
System.out.println("Error in io : " + e.toString());
}
catch(MediaException e)
{
System.out.println("Error in media : " + e.toString());
}
}
you should add this function in function that you want played syncronized .
public void keypress()
{
playmusic(file);
}
for animation you can make any arbitary function like this
syncronized void animation()
{
x++;
group.setTranslation(x,y,z);
}
this function force to moving a group in x axis without stop!
this was a sample way for animation and sound in java 3d game.
Trump admin plans raid in Chicago on ‘illegal immigrants’ right after
taking office: Report - Hindustan Times
-
1. Trump admin plans raid in Chicago on ‘illegal immigrants’ right after
taking office: Report Hindustan Times
2. Chicago food cart vendors, ...
15 minutes ago
0 comments:
Post a Comment