In a card game I have currently the hand at the bottom placed in an ugly linear corner, but actually would like to change that to an arc:
Unfortunately my math skills are very rusty now (at the age of 40; I was quite good at math as a teen, participated in math olympiades etc...) so I hope someone will give me a jump start.
All cards (dimensions:
2 _dx and
2 _dy) have their origin point in the middle (i.e. they are rotated around their middle) and I place them by calling the method
card.place(x, y, rotation) where the x/y origin point is in the left top corner (as usual for computer stuff).
The cards as you see them on the screenshot above are placed from left to right using the index
i (because they are sorted by color and rank already at the server) using this call:
// 12 cards (1 full) should fit into table width, // but the gap shouldn't exceed card width of "2 _dx" var horizGap:Number = Math.min(width / 13, 2 * _dx); var leftMargin:Number = (width - 13 * horizGap) / 2; card.place(leftMargin + horizGap * (i + 1), // OK height - 3 * _dy + (_dy/5) * Math.abs(i - 5), // MUST CHANGE 4 * (i - 5)); // OK
I think the
x and the
rotation (i.e. the first and the last arguments in the above call) are okay and I just need to change the second argument (the
y) to get a nicer looking arc.
The playing table component has dimensions
I probably should use
(x - width/2) ^ 2 to get an arc, correct?