How would I get it to display my last image after all frames have finished playing instead of a just a blank white box?
For something that only plays through once I'd usually just do something like this - a rule that is looking for your last frame before carrying out its rules - and the rules it has are empty (i.e. do nothing) - and in the otherwise section place the stuff you want to happen before you get to the last frame.
So basically the rule is saying: when the frame number is (in this example) 20 then do nothing (i.e. stop) . . . but until we reach frame 20 then play through the image sequence.
You can use any frame number you like as the stop point.
I can´t get the offset to work properly. My images is called Pirate_40 and goes upto Pirate_53
So it´s 14 frames and I want the framerate to be 10
So it should be
Constrain attribute: self.image to "Pirate_"..(floor(( self.Time*10)+40)%14)
But it dosen´t work, it only plays from another animation which goes from Pirate_0 to Pirate_12
Any idea how to do?
@Fajlajp said:
I can´t get the offset to work properly. My images is called Pirate_40 and goes upto Pirate_53
So it´s 14 frames and I want the framerate to be 10
So it should be
Constrain attribute: self.image to "Pirate_"..(floor(( self.Time*10)+40)%14)
But it dosen´t work, it only plays from another animation which goes from Pirate_0 to Pirate_12
Any idea how to do?
. . .
Quoted from the OP.
@Socks said:
► The above example assumes an image sequence starting on frame '0' and having no file name, just the numbers (so basically an image sequence going 0, 1, 2, 3, 4, 5 . . . etc [see attached file's image sequence for an example of this]). But If your frame doesn't start on 0, but instead starts on 1 then simply add 'plus 1' like this:
Hi guys, I tried this, but I get stuck every single time.
I have 30 fps, 50 images. But I don't know how to stop animation, I'm using it for explosion animation after touch is pressed.
I got stuck on many issues.
I can make it to start from first and to run on touch, that part is good.
I can't make it stop, it runs over and over again, no matter what I do.
If I remove %50 (it doesn't run at all)
@Kova said:
Hi guys, I tried this, but I get stuck every single time.
I have 30 fps, 50 images. But I don't know how to stop animation, I'm using it for explosion animation after touch is pressed.
I got stuck on many issues.
I can make it to start from first and to run on touch, that part is good.
I can't make it stop, it runs over and over again, no matter what I do.
If I remove %50 (it doesn't run at all)
When I have it alone in project, works fine. When I have some other rules, doesn't work, could you help me setup project. When I touch actor *image to do animation and stop after running once?
I found it Socks, I really did, I read all this like 10 times now
Ok, I got it after touch to run once, but it looks like it skipped many frames, as it is 50 images, should be for 25fps (2sec), but it is much shorter. If I loop it then first it skips some, then goes from start, and looks good.
Ok, what your saying is. %x Modulus limits up to a certain number before repeating, and the +x part is the number it starts the count at, going in a loop.
So if I had 100 image files, name Filename_00 and up, and images 20 to 50 pertained to a run motion. The below code would loop said animation from 20 to 50 repeatedly?
@Franto said:
So if I had 100 image files, name Filename_00 and up, and images 20 to 50 pertained to a run motion. The below code would loop said animation from 20 to 50 repeatedly?
@Socks Thanks for the correction, and about floor's removal, reason I thought it wasn't needed was that it was mentioned earlier in the thread that removing floor from the equation still yielded the same result even if there were decimals, perhaps it was discovered later that it was not a good idea?
@Franto said:
Socks Thanks for the correction, and about floor's removal, reason I thought it wasn't needed was that it was mentioned earlier in the thread that removing floor from the equation still yielded the same result even if there were decimals, perhaps it was discovered later that it was not a good idea?
Yep, you need to read the whole thread, the floor function is needed.
@bobarino said:
Rather than basing the FPS on the velocity of the actor, I'm trying to base it on the velocity of a different actor. Ex: I have the 'background actor' moving to simulate motion and i need the 'main characters' animation FPS to be base off of the background moving speed. (the 'main character' remains centered at all times, and the 'Background actor' is a moving backdrop which wraps continuously) As the background speeds up, the main character animation speeds up.....?
Constrain image to floor( Insert FPS here )%21
Constrain image to floor( background linear velocity divided by some suitable number that scales to your animation frame numbering )%21
@Chimoru said:
Perfect! Thank you for the quick response.
You could also dump the two Interpolate rules and do it with a single constrain behaviour, like this, Constrain image to . . .
. . . . . . . . . .
round(10 *cos(( game.Time *200)+180)+10)
. . . . . . . . . .
200 is the speed.
The two 10's are the sum of the range of frames.
The 180 is the starting point within the sequence.
(180° = starting at the first frame, 0° = starting at the last frame)
So looping back and forth over a 40 frame sequence called "trapdoor_1" "trapdoor_2" "trapdoor_3" (. . .) would look like this . . .
Nice! I like the cosine method, but is there any way to make the sequence play linearly using one constrain? Since cosine tapers off the framerate doesn't stay the same and the last frames are shown for longer. Maybe a different function?
@Chimoru said:
. . . Since cosine tapers off the framerate doesn't stay the same and the last frames are shown for longer. . . .
Yep, the only reason I posted that was that when doing the 2 Interpolate rules version I noticed how much nicer it looked with ease in and ease out engaged (especially at higher frame rates) . . . but yes, the cos/sin version will dampen into the end points, I'm sure there's a single constrain calculation that will produce a linear version, I'll give it some thought . . . . .
Hellow forum, This is my first post and first month of gamesalad.
Im having a problem using this method to animate a character. He moves at a liner velocity of 80 and I want him and the animation to slow down when he is in contact with a goop actor.
This is the math Im using "char_run"..floor(self.time*(self.motion.linear velocity.x/10))%4
The problem is that a white box apears when "char_run2" is supposed to be displayed
If I add a +1 at the end the white box doesn't appear but it skips the 2nd frame.
My frames are named char_run1,char_run2,char_run3,char_run4
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
The mod() or % function will return the remainder of a division problem. So x%4 or mod(x,4) will return the remainder when x is divided by 4. Possible values of the second part of the expression are 0, 1, 2, or 3. So what's happening is that you are getting char_run0 when dividing a multiple of 4 by 4. Adding one should result in values of 1, 2, 3, or 4. If it doesn't, then something else is wrong and I'm not sure what that might be. I would recommend using an Every 0 seconds timer with a Log Debugging Statement with that expression and checking the Log Debugger window to see if you ever get char_run2.
Thank you for the speedy reply!
I fixed it by adding a - to self.motion.velocityx / (self.time*(-self.motion.linear velocity x/10))
For some reason the animation was runing in reverse and adding the - fixed both issues.
Comments
I can´t get the offset to work properly. My images is called Pirate_40 and goes upto Pirate_53
So it´s 14 frames and I want the framerate to be 10
So it should be
Constrain attribute: self.image to "Pirate_"..(floor(( self.Time*10)+40)%14)
But it dosen´t work, it only plays from another animation which goes from Pirate_0 to Pirate_12
Any idea how to do?
Any idea how to do?
. . .
Quoted from the OP.
"Pirate_"..floor((self.Time*10)%14)+40
Sorry, my misstake, I did like that "Pirate_"..floor((self.Time*10)%14)+40
Just wrote wrong here
Hi guys, I tried this, but I get stuck every single time.
I have 30 fps, 50 images. But I don't know how to stop animation, I'm using it for explosion animation after touch is pressed.
I got stuck on many issues.
I can make it to start from first and to run on touch, that part is good.
I can't make it stop, it runs over and over again, no matter what I do.
If I remove %50 (it doesn't run at all)
You have probably set it up incorrectly.
When I have it alone in project, works fine. When I have some other rules, doesn't work, could you help me setup project. When I touch actor *image to do animation and stop after running once?
Then I would guess the issue might be with the other rules.
I think that's been mentioned a couple of times somewhere in this thread already . . . . hold on . . . yes, it is at the top of this page.
I found it Socks, I really did, I read all this like 10 times now
Ok, I got it after touch to run once, but it looks like it skipped many frames, as it is 50 images, should be for 25fps (2sec), but it is much shorter. If I loop it then first it skips some, then goes from start, and looks good.
Maybe it's preview thing as I'm on PC.
It's impossible to say as I know nothing about your project, maybe test it on an iPad/Phone/Android ?
Ok, what your saying is. %x Modulus limits up to a certain number before repeating, and the +x part is the number it starts the count at, going in a loop.
So if I had 100 image files, name Filename_00 and up, and images 20 to 50 pertained to a run motion. The below code would loop said animation from 20 to 50 repeatedly?
Filename_((self.Time*30)%50)+20
It would be:
"Filename"..floor(self.time*30)%31+20
@Socks Thanks for the correction, and about floor's removal, reason I thought it wasn't needed was that it was mentioned earlier in the thread that removing floor from the equation still yielded the same result even if there were decimals, perhaps it was discovered later that it was not a good idea?
Yep, you need to read the whole thread, the floor function is needed.
you just gave me a reason to delete a couple projects. youre so smart socks!
Constrain image to floor( Insert FPS here )%21
Constrain image to floor( background linear velocity divided by some suitable number that scales to your animation frame numbering )%21
This is a great method! Here's a tricky problem I'm trying to solve to no avail:
play the sequence up to a certain frame, and then play the sequence backwards.
I can't seem to figure out a solution using this method. Any ideas?
A simple way to do this would be . . .
Constrain self.image to round(X)
Rule
--When X = 0
----Interpolate X to 12
Rule
--When X = 12
----Interpolate X to 0
. . . . .
Edit: example attached.
Perfect! Thank you for the quick response.
You could also dump the two Interpolate rules and do it with a single constrain behaviour, like this, Constrain image to . . .
. . . . . . . . . .
round(10 *cos(( game.Time *200)+180)+10)
. . . . . . . . . .
200 is the speed.
The two 10's are the sum of the range of frames.
The 180 is the starting point within the sequence.
(180° = starting at the first frame, 0° = starting at the last frame)
So looping back and forth over a 40 frame sequence called "trapdoor_1" "trapdoor_2" "trapdoor_3" (. . .) would look like this . . .
"trapdoor_"..round(20 *cos(( game.Time *200)+180)+20)
Nice! I like the cosine method, but is there any way to make the sequence play linearly using one constrain? Since cosine tapers off the framerate doesn't stay the same and the last frames are shown for longer. Maybe a different function?
Yep, the only reason I posted that was that when doing the 2 Interpolate rules version I noticed how much nicer it looked with ease in and ease out engaged (especially at higher frame rates) . . . but yes, the cos/sin version will dampen into the end points, I'm sure there's a single constrain calculation that will produce a linear version, I'll give it some thought . . . . .
Here's a linear version!
"framerate" is a decimal, I found .32 to be around 16 FPS, and it oscillates linearly between 0 to "maxFrame". It's based on a triangle wave function.
Thanks! this'll help with optimisation!
Neat ! And useful !!
Hellow forum, This is my first post and first month of gamesalad.
Im having a problem using this method to animate a character. He moves at a liner velocity of 80 and I want him and the animation to slow down when he is in contact with a goop actor.
This is the math Im using "char_run"..floor(self.time*(self.motion.linear velocity.x/10))%4
The problem is that a white box apears when "char_run2" is supposed to be displayed
If I add a +1 at the end the white box doesn't appear but it skips the 2nd frame.
My frames are named char_run1,char_run2,char_run3,char_run4
The mod() or % function will return the remainder of a division problem. So x%4 or mod(x,4) will return the remainder when x is divided by 4. Possible values of the second part of the expression are 0, 1, 2, or 3. So what's happening is that you are getting char_run0 when dividing a multiple of 4 by 4. Adding one should result in values of 1, 2, 3, or 4. If it doesn't, then something else is wrong and I'm not sure what that might be. I would recommend using an Every 0 seconds timer with a Log Debugging Statement with that expression and checking the Log Debugger window to see if you ever get char_run2.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thank you for the speedy reply!
I fixed it by adding a - to self.motion.velocityx / (self.time*(-self.motion.linear velocity x/10))
For some reason the animation was runing in reverse and adding the - fixed both issues.