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

2021/1/20

scaling an image properly

ancalagorn ancalagorn

2021/1/20

#
Hello to everyone I am trying to make asteroids and i have a class Asteroids representing the rocks. I would like to know what is the difference between the commands below that change the size of the rocks 1) getImage().scale(x,y) 2) Asteroids image=getImage() image.scale(x,y) setImage(image) Both ways change the visible size of the rocks but only the second way change the actual attributes: imageWidth, imageHeight of the Asteroids object. The first way sometimes gives me trouble when my spaceship gets near a rock: though is not touching the rock it explodes as if it had touched it. I assume it is relevant to how i scale the image of the rock with the first way but maybe i am wrong. I am looking forward for your suggestions
danpost danpost

2021/1/20

#
I think it is just the way it is, in that when scaling an image of an actor, collision data is not updated. Using setImage after scale will have the collision data updated.
ancalagorn ancalagorn

2021/1/21

#
danpost thank you for your reply but what do you mean when you refer to collision data;
danpost danpost

2021/1/21

#
ancalagorn wrote...
what do you mean when you refer to collision data;
"behind the scene" stuff Greenfoot does.
ancalagorn ancalagorn

2021/1/21

#
I hear you. The reason i ask is because i am a school teacher and on of my students told me about this problem and when i looked at it i found out that most of the time it's ok and only sometimes this problem appeared in the game and i didn't know how to explain it (i still don't) because i'm not java expert. Anyway thanks
You need to login to post a reply.