Math Logic between rotation and size
zweg25
Member Posts: 738
Hi everyone,
So for a game being scaled down from iPad to iPhone 5 I need to change the size of an actor. It's width needs to be 60 and height 45. My dilemma is that my actor rotates, so the width and height need to change accordingly.
To clarify, instead of the width, I need the horizontal length of the actor to stay at 60, no matter what the rotation is. And the vertical distance to stay at 45. So at rotation 0: width=60 height=45, rotation 90: width=45 height=60.
Is there a math way to constrain the size of the actor based on it's rotation?
Hopefully you understand what I am asking
Thanks
zweg25
Comments
If I understand your question correctly once you change the width and height attributes they will remain fixed no matter what the rotation is just like it does in the iPad version.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
The actual width and height of the actor remains the same, however the Height from top to bottom of the actor is going to be larger than 60 (when it reaches 45 degrees) in relation to the scene. (not sure if this is relative or not to the question.
However I am not quite understanding the example you have given, how does height change to 90 when the width previously was 60? Is it easier to make a square rather than a rectangle?
What would help here is to have a sketch of what you intend to happen. Can you, for example, show the actor at 0°, 45°, and 90°?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Most confusing question of the week !
It doesn't help using terms like 'width', 'horizontal length', 'vertical distance' . . . . and so on, for example what is 'vertical distance' ? Do you mean 'height' ?
The idea that you want to keep the 'horizontal length' at 60 and the 'vertical distance' (distance from what?) at 45 is almost meaningless without further explanation.
Can you sketch out a couple of images of the actor in its various positions ?
I agree regarding how confusing the question is
I must be missing something fundamental, as if the width and height stay the same as it rotates, then surely you can just resize the image and you're good to go.
If the width and height adapt as it rotates so that as it rotates the long side becomes the short and the short side becomes the long side... why is it rotating at all? Is the rotation even visible to the user?
But more importantly, if you have the actor working at the original size, you must already have any such code in place for the bigger version. Perhaps post that?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Sorry that 90 screwed everything up, its suppose to be 60.
I am not great with photoshop, but here is a rough sketch of what I mean.
I am using a rainbow oval, to hopefully make it easier to see
Hopefully this explains it a little bit better
That's definitely starting to clear things up. I can see how the rotation would be visible to the user, definitely. But I'm not understanding the middle image. If the start shape is the first image, and the end shape is the third image, they're both the same shape, ignoring the rainbow. How is the 2nd shape/position being reached? It isn't a transitory shape or position between the two others. To move from one to three while hitting two inbetween it would surely have to wobble up and down again?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
I am not understanding what you are saying?
The actor has a rotate behavior, that is how it reaches that state. But I need to be able to make the size of the actor change according to its rotation
Oh wait I understand, let me fix the photoshop image
Sorry, now people might be even more confused
I am not sure if the second position's height and width are correct (I could have been wrong on the math).
EDIT: @Armelline maybe I am not understanding what you are saying still? Sorry to make this so confusing everyone
Sorry, I'm still not clear on how the middle picture - when ignoring the rainbow - is a step between the top and bottom. Could you put a couple more in, between 1 and 2 and between 2 and 3?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Ultimately I'm asking, I guess, if the width and height would have to change at all if the image inside could rotate without them doing so.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
I made it rainbow to help see the change. Are you confused because of what I wrote for width and height?
Should I also label where the width and height are in every picture?
So as far as the user is concerned, the white outline would not change?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Yes, but this is not the image I am using. In my image there is no white outline
I am not allowed to show the image I am using, sorry
That's okay, I'm just trying to understand what it is you're trying to achieve. Will the image not get badly distorted as it's scrunched up as it rotates?
Is there a reason in the game that it actually needs to rotate, rather than just appear to rotate?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
No, it won't.
What I am trying to achieve is scaling the game down from iPad to iPhone 5. On the iPhone I need to change the size of the image to 60x45, so it is not distorted. But as it rotates it needs to maintain that size (vertically and horizontally), to look correct
You are achieving the rotating effect on the larger image?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
For some reason in the game, if I keep the actor the same size, it gets distorted
But the actor behaves as expected on iPad?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
yes
Maybe I should just rethink this
Could you post the code you use to tranform it as it rotates on iPad?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Maybe. But what I get from your last set of images is that you want a "mask" effect where the internal rainbow stripes rotate but the border oval shape does not change size nor rotate at all.
Imagine a really large circle that is rainbow stripe colored and rotates but we only see the mask of the oval shape while that's happening. This is something that's easily achieved in Photoshop but not as easily in GameSalad, though it is possible to mask depending on what else is going on on the scene.
@Socks @Armelline Does that make sense to you?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@zweg25, can't you just use "crop/overscan" instead of "stretch" for iPhone 5? This would not cause any distortion.
Assuming your project is portrait, you would just leave some extra space left and right on the iPad version (filling it up with a border or just extended background). This part would just be cropped away on iPhone.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
I'm not sure it makes sense (is logical) for a circle to rotate whilst constraining its width and height to a non-uniform ratio and not have it go outside those limits (60/45), as it turns it will necessarily have to breach 60/45 to actually reach 60/45 !
Maybe I still don't quite understand the question.
You can get something to stick to a certain size based in its rotation by simply referencing either the rotation or the sin (or cos) of that rotation, it should look something like this . . . .
constrain width to 7.5 x [cosine of rotation x 2] + 52.5
constrain height to 7.5 x [[sine of rotation -45°] x 2]] + 52.5
There may well be an error in that, not at my computer right now, but I'll be back in a couple of hours and try it out, but like I say getting the circle to hit 60 at 0° and then 45 at 90° means it will drift beyond these limits . . . . I hope that makes sense !?
@Socks, I think @zweg25 is just trying to compensate for the distortion in stretch mode when playing an iPad project on iPhone. If round circles is crucial, overscan/crop is probably the only way to go.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
It makes sense, but maybe I should rethink the way I want this to be
Thanks for the help everyone
Sorry for the trouble, trying @Socks way kinda works. Just playing with the numbers a little and it almost worked perfectly
Thanks!