Data Realms Fan Forums
http://45.55.195.193/

Viewing one frame in a split-second, then normal animation
http://45.55.195.193/viewtopic.php?f=73&t=31670
Page 1 of 1

Author:  Djinn [ Thu Sep 06, 2012 4:45 am ]
Post subject:  Viewing one frame in a split-second, then normal animation

Back with more secretive Lua questions. More animation questions, but this time it's something specific. The idea is to flash one frame for the bare minimum time possible before continuing on at a given rate with the others. I need to do this because I want to make trees that can collide with MOs or vice versa as it grows, and flashing the last frame it sets the collision for everything before it. Otherwise the collision is set for the first (and smallest sized) frame. I'm attempting to work around by having the first frame be the fully grown tree, then the second and onwards being from small to big. When I try this code however, it just locks it on one frame, or seems to. Without the >>indicated<< bit, the plant iterates through the frames to the last one and stays there, as intended. Any ideas?

Code:
function Create(self)
   self.animTimer = Timer()
   
   self.frameChangeTime = 200 -- This is the time interval between changing frames (In miliseconds).
   
   self.Flashframe = 1
   self.startFrame = 2
   self.maxFrame = 12 -- This is the frame at which you want the animation to stop at.
end

function Update(self)
   >>>>if self.Frame = self.Flashframe then
      self.Frame = self.startFrame
   end <<<<<

   if self.Frame >= self.maxFrame then
      self.Frame = self.maxFrame
   else
      if self.animTimer:IsPastSimMS(self.frameChangeTime) then
         self.Frame = self.Frame + 1
         self.animTimer:Reset()
      end
   end
end

Author:  Coops [ Thu Sep 06, 2012 11:48 am ]
Post subject:  Re: Viewing one frame in a split-second, then normal animation

I always loved working with frames in lua.

First things first, in the indicated bit

Code:
if self.Frame = self.Flashframe then


should be

Code:
if self.Frame == self.Flashframe then

Author:  Djinn [ Thu Sep 06, 2012 2:52 pm ]
Post subject:  Re: Viewing one frame in a split-second, then normal animation

Coops wrote:
I always loved working with frames in lua.

First things first, in the indicated bit

Code:
if self.Frame = self.Flashframe then


should be

Code:
if self.Frame == self.Flashframe then


Yeah, you work with the transforming gun-sprite in the crawler in your Aco faction inspired a crazy idea for me that I'm not sure if I can pull off yet!

Either way, this now works, except that there's still a visible flash of the first frame for a second. I'm not sure that I can cut it down any more, even by changing the frame change time. Thoughts?

Code:
function Create(self)
   self.animTimer = Timer()
   
   self.frameChangeTime = 0 -- This is the time interval between changing frames (In miliseconds).
   
   self.Flashframe = 1
   self.startFrame = 2
   self.maxFrame = 12 -- This is the frame at which you want the animation to stop at.
   
   if self.Frame == self.Flashframe then
      self.Frame = self.startFrame
   end
end

function Update(self)
   if self.Frame == self.startFrame then
     self.frameChangeTime = 1500
   end

   if self.Frame >= self.maxFrame then
      self.Frame = self.maxFrame
   else
      if self.animTimer:IsPastSimMS(self.frameChangeTime) then
         self.Frame = self.Frame + 1
         self.animTimer:Reset()
      end
   end
end

Author:  Shook [ Tue Sep 11, 2012 6:54 pm ]
Post subject:  Re: Viewing one frame in a split-second, then normal animation

I doubt it, the very first frame where an object is created seems to be impossible to touch with Lua (Create(self) takes the first frame after that). However, if you use Lua to spawn it and set its Scale to 0 before adding it, then setting it back to 1 as the first possible thing, then it might work.

Author:  Djinn [ Thu Sep 20, 2012 3:59 pm ]
Post subject:  Re: Viewing one frame in a split-second, then normal animation

Shook wrote:
I doubt it, the very first frame where an object is created seems to be impossible to touch with Lua (Create(self) takes the first frame after that). However, if you use Lua to spawn it and set its Scale to 0 before adding it, then setting it back to 1 as the first possible thing, then it might work.


This works beautifully and perfectly, by the way.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/