playing with scale.

Monkey Forums/Monkey Programming/playing with scale.

Paul - Taiphoz(Posted 2012) [#1]
Sup all.

would seem that scale works different than I'm used to.

I have my class, which has a drawing method, my class has fields for scalex and scaley, these values are then used not only for drawing, but also scaling up collision checks and other stuff.

I thought it would be a simple matter of placing in my draw method, scale scalex,scaley and then at the bottom of the method, setting the same back to 1 with scale 1,1 but this seems not to work as I expect.

can some one inform me as to how this should be done now. thanks.


JIM(Posted 2012) [#2]
Scale is relative, so Scale 1, 1 never does anything.

There's 2 options:

1. PushMatrix at the start of draw, scale scalex, scaley, PopMatrix
2. Scale Scalex, Scaley, then use Scale 1.0 / Scalex, 1.0 / Scaley

I strongly recommend the first option. What it does is push the current transformation matrix on the stack. That way, when you're done using the modified matrix you can just pop it and you'll be back to the old transformation.

Note: A transformation matrix contains: translation, rotation and scale


Paul - Taiphoz(Posted 2012) [#3]
Ah push n pop. got it, thanks mate that worked a treat.

I see that does the full matrix so assume that also does rotations as well ?


DruggedBunny(Posted 2012) [#4]
@Taiphoz: take a look at bananas/hitoro/matrixrocks and /rotationsickness, which should hopefully help.