OZONE Asylum
Forums
Multimedia/Animation
Isometric projection in Flash.
This page's ID:
29525
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Sure. [code]// --- Functions --- // Convert isometric coordinates to Flash X coordinate xFla = function (x, y, z) { return ((x-z)*isoCos); }; // Convert isometric coordinates to Flash Y coordinate yFla = function (x, y, z) { return (-(y+(x+z)*isoSin)); }; // Convert Flash X and Y and altitude coordinates to isometric X coordinate xIso = function (xF, yF, y) { return ((xF)/isoCos-(yF+y)/isoSin)/2; }; // Convert Flash X and Y and altitude coordinates to isometric Y coordinate (actually Z, but I don't give a hoot) yIso = function (xF, yF, y) { return (-((xF)/isoCos+(yF+y)/isoSin))/2; }; // --- Variables --- // isoCos and isoSin are defined in variables so they don't have to be calculated every time the functions are executed isoCos = Math.cos(0.46365); isoSin = Math.sin(0.46365); // --- Example Use --- // This example shows mostly why I wanted the new functions isoWorld_mc.onMouseUp = function() { // Let's put _xmouse and _ymouse into isometric coordinates isoMouseX = xIso(_xmouse, _ymouse, 0); isoMouseY = yIso(_xmouse, _ymouse, 0); // Let's round it to the nearest 100 isoMouseSnapX = Math.round(isoMouseX/100)*100; isoMouseSnapY = Math.round(isoMousey/100)*100; // Let's convert them back to Flash coordinates flaMouseX = xFla(isoMouseSnapX, 0, isoMouseSnapY); flaMouseY = yFla(isoMouseSnapX, 0, isoMouseSnapY); // Now, let's change the position of this sucker this._x -= flaMouseX; this._y -= flaMouseY; };[/code] Hope someone may find this helpful! :) [url=http://www.zavaboy.com][img]http://asylum.zavaboy.com/zavaboy.gif[/img][/url] [small](Edited by [url=http://www.ozoneasylum.com/user/4778]zavaboy[/url] on 09-15-2007 16:22)[/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »