|
Author |
Topic: rotate a image around his origin (Read 335 times) |
|
capeta
|
rotate a image around his origin
« on: Nov 30th, 2004, 5:23am » |
|
lets change this: does anybody knows how to rotate a image (ie:sprite) without rotating the whole scene ? i just want the image to face some point. any one ?
|
« Last Edit: Dec 1st, 2004, 3:31am by capeta » |
|
|
|
|
st33d
|
Re: rotate a image around his origin
« Reply #1 on: Dec 2nd, 2004, 2:23am » |
|
As far as I know the whole scene shouldn't rotate. If you use the rotate() comand it only changes the co-ord system not the stage. In order to get your image to face a direction you're probably going to have to re-draw the background anyway and that should take no time at all with a loaded image. I've butchered the sprite demo by the Presstube geezer to demonstrate an example of something rotating with a static scene. I this case 1.gif is a 20,20 image and 2.gif is a 40,40 image. Code: Sprite one,two; float theta = 0; void setup(){ size(40,40); one = new Sprite("1.gif"); two = new Sprite("2.gif"); framerate(24); } void loop(){ two.display(0,0); push(); theta = (theta+0.1)%360; translate(10,20); rotate(theta); one.display(0,0); pop(); } class Sprite{ BImage i; Sprite(String imageName){ loadImages(imageName); } void loadImages(String name){ i = loadImage(name); } void display(float xpos, float ypos){ image(i, xpos, ypos); } } |
| Was this what you meant?
|
I could murder a pint.
|
|
|
capeta
|
Re: rotate a image around his origin
« Reply #2 on: Dec 2nd, 2004, 7:57pm » |
|
yes thank you! i just needed someone to explain me pop() and push(). all clear now!
|
|
|
|
|