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

2012/12/10

Animation

TomazVDSN TomazVDSN

2012/12/10

#
Hi, I was able to create an animation using the AnimatedActor developed by Michael Kolling, and it work fine with my little robots. However I was able to create an object made of objects. For Example, I want to put a little light on the top of the robot's head. that green like will blink continuously but I want to be able to change the light to yellow and then red according to the environment. How do I create an object which is the some of several other objects ?
danpost danpost

2012/12/10

#
You can change the image of an object at any time using one of the 'setImage' methods in the Actor class. You also have available to you the image altering methods in the 'GreenfootImage' class. The 'getImage' method in the Actor class returns a GreenfootImage object.
TomazVDSN TomazVDSN

2012/12/11

#
Thank you, i am quite sure there are classes and methods I can do animation, as I did it. however I have this challenge of creating an object Obj which is the integration of several other objects ( obj1, obj2, obj3...) For example, I want to create a Dog which is dogHead, dogBody, dogTale, dogMouth, dogLegs. There is a class for each part of the Dog, and each part ( object ) will respond accordingly to the environment. if food is close the dog will open the mouth. if a cat is close the dog will run ( legs will move ). if a toy is around or the dog owner is close the dog will move the tale. So how do I integrate the obj dogBody, obj dogTale, obj dogMouth, and obj dogLegs in one single object. When the legs move the tale, the mouth and the body will move together. Or even simpler, a ambulance running and the lights turning blue and red... So how do I connect object A1 with object A2, and objecj A3 ? A helicopter, blades, and man getting in and out ? Regards,
danpost danpost

2012/12/11

#
Create a superclass (sub-class of Actor) called Dog and create sub-classes of Dog for the tail, the legs, the mouth, whatever. Let the image of the Dog class itself be the body of the dog. In that class, declare and assign the appropriate body parts needed for one dog. Add a 'addedToWorld(World world)' method to the Dog class to add the body parts into the world and call a method in that class that correctly places the body parts with respect to where the body is (and which way it is facing). It would be easiest to have the images of the parts almost twice as big as the size of the body part so you can just rotate the object for its motion (the center of the image is the pivot point -- where the connecting joint should be). Let the Dog class (the body) control the other parts of the body.
TomazVDSN TomazVDSN

2012/12/12

#
Thank you, I will try and let you and our colleagues to know the result.
You need to login to post a reply.