Advertisement
Guest User

Untitled

a guest
Jul 30th, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.30 KB | None | 0 0
  1. for i,v in pairs(self) do  ---start loop on all assets
  2.         if(type(v) == "table" and v.name ~= nil)then---------loop on those with name
  3.             v.x = GameObjref.x + self.globalOffsetX;
  4.             v.y = GameObjref.y + self.globalOffsetY;
  5.       if(v.Oangle == nil)then v.Oangle = 0; end
  6.       v.angle = v.Oangle + GameObjref.angle
  7.      
  8.             if(v.Oangle == 0)then
  9.                 v.scaleX = GameObjref.scaleX
  10.         v.scaleY = GameObjref.scaleY
  11.             else
  12.                 v.scaleY = GameObjref.scaleX
  13.         v.scaleX = GameObjref.scaleY
  14.             end
  15.      
  16.       ----Animation nation
  17.       if(v.visible == true)then
  18.         for i2,v2 in pairs(self.animation[1][self.animation[2]]["Part"]) do
  19.           local Name = v2["-name"];
  20.           local index = string.find(Name,"$",1,true)
  21.  
  22.           local found = false
  23.  
  24.           if(index ~= nil)then
  25.             if(string.sub(Name,0,index-1) == string.sub(v.name,0,index-1))then
  26.               found = true
  27.             end
  28.           end
  29.  
  30.           if(Name == v.name)then found = true end
  31.  
  32.  
  33.           if(found)then ---start found
  34.               local table = self.animation[1][self.animation[2]]["Part"][i2]["Frame"]
  35.               local prevTable = table[self.frame]
  36.               local nextTable = table[(self.frame%(#table))+1]
  37.  
  38.               if(self.stateTrans)then
  39.  
  40.                 nextTable = table[1]
  41.                 table = self.animation[1][self.lastState]["Part"][i2]["Frame"]
  42.                 if(self.lastFrame > #table)then self.lastFrame = #table; end
  43.                 prevTable = table[self.lastFrame]
  44.                 local temp = {};
  45.  
  46.                 temp["-x"] = v.px;
  47.                 temp["-y"] = v.py;
  48.                 temp["-rotation"] = v.pangle;
  49.                 temp["-scaleX"] = v.pscaleX;
  50.                 temp["-scaleY"] = v.pscaleY;
  51.                 temp["-alpha"] = v.palpha
  52.                 temp["-colorMatrix"] = v.pmatrix;
  53.                 prevTable = temp;
  54.  
  55.  
  56.                 factor = (self.stateCount/self.stateCountMax)
  57.               end
  58.  
  59.               local X = (nextTable["-x"] -prevTable["-x"]) * factor + prevTable["-x"]
  60.               local Y = (nextTable["-y"] -prevTable["-y"]) * factor + prevTable["-y"]
  61.               local SCALEX = (nextTable["-scaleX"] -prevTable["-scaleX"]) * factor + prevTable["-scaleX"]
  62.               local SCALEY = (nextTable["-scaleY"] -prevTable["-scaleY"]) * factor + prevTable["-scaleY"]
  63.  
  64.               local angDif = nextTable["-rotation"] -prevTable["-rotation"]
  65.  
  66.               local multFactor = 1;
  67.  
  68.               if(self == joeref)then
  69.                 if(self:getCurrentFrame() == "Run")then
  70.                   multFactor = self.animationSpeed
  71.                 end
  72.               end
  73.  
  74.               local ANGLE = (angDif) * factor + (prevTable["-rotation"]  * multFactor)
  75.  
  76.               local ALPHA = (nextTable["-alpha"] -prevTable["-alpha"]) * factor
  77.  
  78.               XY[1][1] = X; XY[1][2] = Y;
  79.               XY = matrix.mul(XY,rotMatrix);
  80.  
  81.               local oldX = X;
  82.               local oldY = Y;
  83.  
  84.               X = XY[1][1];
  85.               Y = XY[1][2];
  86.  
  87.               v.x =  v.x + (X) * self.GameObj.scaleX
  88.               v.y =  v.y + (Y) * self.GameObj.scaleY
  89.  
  90.              
  91.               v.scaleX = v.scaleX * SCALEX
  92.               v.scaleY = v.scaleY * SCALEY
  93.              
  94.  
  95.               if(math.abs(angDif) < 180)then
  96.                 v.angle = v.angle + (ANGLE* (math.pi/180)) *  (v.scaleX / (math.abs(v.scaleX)))
  97.               else
  98.                 angDif = angDif + 360
  99.                 ANGLE = (angDif) * factor + prevTable["-rotation"]
  100.                 v.angle = v.angle + (ANGLE* (math.pi/180)) *  (v.scaleX / (math.abs(v.scaleX)))
  101.               end
  102.  
  103.  
  104.               if(self == joeRef)then
  105.                 if(self:getCurrentFrame() == "Run")then
  106.                   v.angle = v.angle * self.animationSpeed
  107.                 end
  108.               end
  109.  
  110.  
  111.               v.alpha = prevTable["-alpha"] + ALPHA
  112.              
  113.               if(prevTable["-colorMatrix"] ~= nil)then
  114.                 if(v.colorTransform == nil)then v.colorTransform = {}; v.colorTransform.PixelEffect = shadRef["ColorTransform"] end
  115.                 local difTable = {};
  116.                 local cPrevTable = prevTable["-colorMatrix"]
  117.                 local cNextTable = {};
  118.                 if(nextTable["-colorMatrix"] ~= nil)then
  119.                   cNextTable = nextTable["-colorMatrix"];
  120.                 else
  121.                   cNextTable = {1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0};
  122.                 end
  123.                 -------------------------
  124.                 for i=1,20,1 do
  125.                   difTable[i] = (cNextTable[i] - cPrevTable[i]) * factor + cPrevTable[i];
  126.                 end
  127.                 ---------------------------
  128.  
  129.                 v.colorTransform.matrix = difTable;
  130.               end
  131.  
  132.  
  133.  
  134.               if(not self.stateTrans)then
  135.                 v.px = (oldX) --* _Joe["Joe"].scaleX;
  136.                 v.py = (oldY) --* _Joe["Joe"].scaleY;
  137.                 v.pscaleX = SCALEX;
  138.                 v.pscaleY = SCALEY;
  139.                 v.pangle = ANGLE
  140.                 v.palpha = v.alpha
  141.                 v.pmatrix = v.colorTransform.matrix;
  142.               end
  143.  
  144.  
  145.  
  146.           end ---end found
  147.  
  148.  
  149.         end
  150.       end
  151.       ----------------------End animation nation
  152.  
  153.         end ---end loop on those with name
  154.     end ---end loop on all assets
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement