This site requires JavaScript, please enable it in your browser!
Greenfoot back
Petr
Petr wrote ...

2019/12/14

i can't turn off my music when i enter next level

Petr Petr

2019/12/14

#
i want to turn of my music but is in actor and i can't take my music to another actor pls help
Super_Hippo Super_Hippo

2019/12/14

#
(Background) music should be handled by the active world. Keep a reference to the GreenfootSound object and stop it when you want it to stop.
Petr Petr

2019/12/14

#
public class enemy extends Actor
{
    /// přidává svět do actora
    MyWorld můjsvět;
    public GreenfootSound mojesongy = new GreenfootSound("Undertale.mp3");
    public static final int nahoru = 270;
    public static final int doleva = 180;
    public static final int dolů = 90;
    public static final int doprava = 0;
    
    /**
     * Act - do whatever the enemy wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // random pohyb po herní ploše 
        if(getWallInFront()==false)
        {
        move (2);
        }else
        {
            int random = Greenfoot.getRandomNumber(3);
            if(random == 0 )
            {
            turn(nahoru);
            }else if(random == 1)
            {
              turn(dolů);
              
            }else if(random == 2)
            {
             turn(doprava);   
            }else if(random == 3) 
            {
                turn(doleva);
            }
        }
        
       
         // oddělaní hráče z herní plochy po doteku z nepřítelem
           Actor hráč = getOneIntersectingObject(hráč.class);
           if(hráč!=null)
          {
             World můjsvět = getWorld();
             konec Konec = new konec();
             restart Restart = new restart();
             můjsvět.addObject(Konec,můjsvět.getWidth()/2,můjsvět.getHeight()/2); 
             můjsvět.removeObject(hráč);
             můjsvět.addObject(Restart,400,150);
             mojesongy.stop();
             
             
               
                
                
                }
             
       
       
    } 
    // funkce zjištůjící doteku zdi z nepřítelem
    private boolean getWallInFront()
    {
      GreenfootImage myImage = getImage();
      int distanceToFront = myImage.getWidth()/2;
      int xoffset = (int)Math.ceil(distanceToFront*Math.cos(Math.toRadians(getRotation())));
      int yoffset = (int)Math.ceil(distanceToFront*Math.sin(Math.toRadians(getRotation())));
      Actor wall = getOneObjectAtOffset(xoffset,yoffset, rock.class);
      return (wall!=null);
    }
    public void přehrátzvuk()
        
    {
       
    }
}
Petr Petr

2019/12/14

#
sorry like this?
Super_Hippo Super_Hippo

2019/12/15

#
You are stopping a sound which never started.
You need to login to post a reply.