View unanswered posts | View active topics It is currently Thu Dec 26, 2024 5:19 am



Reply to topic  [ 5 posts ] 
 Viewing one frame in a split-second, then normal animation 
Author Message
User avatar

Joined: Sun Oct 29, 2006 4:26 am
Posts: 298
Reply with quote
Post 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


Thu Sep 06, 2012 4:45 am
Profile YIM
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post 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


Thu Sep 06, 2012 11:48 am
Profile
User avatar

Joined: Sun Oct 29, 2006 4:26 am
Posts: 298
Reply with quote
Post 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


Thu Sep 06, 2012 2:52 pm
Profile YIM
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post 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.


Tue Sep 11, 2012 6:54 pm
Profile WWW
User avatar

Joined: Sun Oct 29, 2006 4:26 am
Posts: 298
Reply with quote
Post 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.


Thu Sep 20, 2012 3:59 pm
Profile YIM
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.152s | 14 Queries | GZIP : Off ]