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

2019/2/14

Help me pls

Himsul Himsul

2019/2/14

#
I have 2 class in first class i have this function
public void Animation()
    {
        GreenfootImage menu = getImage();
         int x=menu.getWidth();
         int y=menu.getHeight();
        while(y>0)
        {
          {   
            x--;
            x--;
            y--;
            if(x==10) break;
            if(y==10) break;
            if(x%17==0) Greenfoot.delay(1);
            if(x%20==0 )menu.scale(x,y);
          }
          if(x<100) setLocation(getX(),getY()+3);
        }
      
    }
I want when i'm clicking on second object to call this function for first object.
danpost danpost

2019/2/15

#
Himsul wrote...
I have 2 class in first class i have this function << Code Omitted >> I want when i'm clicking on second object to call this function for first object.
With references to these objects:
/** first object class name */ object_1 = /** the first object */;
Actor object_2 = /** the second object */;
(as local variables or fields) in in your World subclass, use
if (Greenfoot.mouseClicked(object_2)) object_1.Animation();
in the act method or a method called from within the act method.
danpost danpost

2019/2/15

#
I am not sure your animation code will produce the results you want. The while loop will complete in one act step, and only the end result will be shown. That is, the actor will teleport to its final position instead of gradually moving there.
Himsul Himsul

2019/2/15

#
I tried that but it crashes. Ty anyway.
You need to login to post a reply.