Question about sprite animation

Hello,

I have an app where I need to show the images from an image sheet. I have a character than is going to be running in one position on the screen and scroll the background for the running effect. I have looked at the docs for the sprite animation but I need to see the best way to do this. 

I want the character to run only when i tap the screen with my fingers. The faster I tap the faster the character runs. So because the sprite animation uses a set time and intervals I doubt I can use that. Should I instead just do a removeSelf on the image and then replace it with the next frame from the image sheet? And since I need to change the speed based on the tapping I assume I can just do this based on the tapping count.

I need to see how to do the tapping count. Because I want the user to tap anywhere on the screen maybe I should use a transparent image over everything and add a tap event listener?

Thanks,

Warren

Individual sprites have a time scale:

https://docs.coronalabs.com/daily/api/type/SpriteObject/timeScale.html

Set a fixed rate in your sequence definition, then adjust the individual sprite’s timeScale to speed up or slow down that sprite’s execution of the animation.

Here is an example of time-scaling:

http://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/09/sprites4.zip

Thanks, I downloaded the sprites4.zip project and ran it. I then used the code from it to show one image sheet with a character running and worked. The one issue I ran into is  the character it set to 530 height and when I run the app the character is much smaller based on the app settings of 960 x 640. Is there a reason this would happen?

I have been reading some posts about the image sheets and some of these were old ones. People are saying to use image sheets twice the size of what you need for some devices to fit on the screen right and then others not. Is there a reference for this somewhere? I would like to show the images the same size on all devices. The only way I know how to do this is to not use image sheets and use newImageRect where I can specify the size of the images and use a timer with removeSelf to replace the image. I would prefer to use the code and examples roaming gamer gave me since it is all automated and I can change the timing on the fly if needed. 

Right now I am setting the screen size to 960 wide x 640 tall for landscape mode and can use newImageRect for the character size I want and will match the screen size. I’m using 16-bit style graphics for this game so it may look fine on an iphone 6+ but have yet to see.

Warren

Never mind, I had the width and height mixed up in the config file. I switched them and works great!

Individual sprites have a time scale:

https://docs.coronalabs.com/daily/api/type/SpriteObject/timeScale.html

Set a fixed rate in your sequence definition, then adjust the individual sprite’s timeScale to speed up or slow down that sprite’s execution of the animation.

Here is an example of time-scaling:

http://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/09/sprites4.zip

Thanks, I downloaded the sprites4.zip project and ran it. I then used the code from it to show one image sheet with a character running and worked. The one issue I ran into is  the character it set to 530 height and when I run the app the character is much smaller based on the app settings of 960 x 640. Is there a reason this would happen?

I have been reading some posts about the image sheets and some of these were old ones. People are saying to use image sheets twice the size of what you need for some devices to fit on the screen right and then others not. Is there a reference for this somewhere? I would like to show the images the same size on all devices. The only way I know how to do this is to not use image sheets and use newImageRect where I can specify the size of the images and use a timer with removeSelf to replace the image. I would prefer to use the code and examples roaming gamer gave me since it is all automated and I can change the timing on the fly if needed. 

Right now I am setting the screen size to 960 wide x 640 tall for landscape mode and can use newImageRect for the character size I want and will match the screen size. I’m using 16-bit style graphics for this game so it may look fine on an iphone 6+ but have yet to see.

Warren

Never mind, I had the width and height mixed up in the config file. I switched them and works great!