I want to make a simple dynamic scene, like the slightly animated background building in Might & Magic Heroes.
Does Renpy support the declaration of Gif images and then display them in the game?(Can dynamic images be displayed correctly?)
If I can't use GIF,things will be more troublesome,because there is no way for MP4 files to have a transparent background.
It is feasible to define many pictures and then combine them into one, but it will be very troublesome, and the game itself will become bloated, because these pictures are too big.
Or is there any other way to solve the problem of dynamic scenes?
Please help!
Can I use animated GIF pictures?
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
-
- Newbie
- Posts: 18
- Joined: Thu Jun 24, 2021 4:12 am
- Contact:
- Ocelot
- Lemma-Class Veteran
- Posts: 2402
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Can I use animated GIF pictures?
No, GIF images are not supported (because it is terribly outdated format). Other animated image formats are not supported, because there wasn't much requests for them at all. (IIRC PyTom considered adding apng support if enough people request it).
Instead you can:
1) Animate your images using ATL:
https://www.renpy.org/doc/html/atl.html ... -atl-block
2) Use Movie sprite backed by video of your animation:
https://www.renpy.org/doc/html/movie.ht ... ie-sprites
Instead you can:
1) Animate your images using ATL:
https://www.renpy.org/doc/html/atl.html ... -atl-block
2) Use Movie sprite backed by video of your animation:
https://www.renpy.org/doc/html/movie.ht ... ie-sprites
< < insert Rick Cook quote here > >
-
- Newbie
- Posts: 18
- Joined: Thu Jun 24, 2021 4:12 am
- Contact:
Re: Can I use animated GIF pictures?
Thank you, I will go back and study the second method carefully.Ocelot wrote: ↑Mon Jul 19, 2021 5:29 am No, GIF images are not supported (because it is terribly outdated format). Other animated image formats are not supported, because there wasn't much requests for them at all. (IIRC PyTom considered adding apng support if enough people request it).
Instead you can:
1) Animate your images using ATL:
https://www.renpy.org/doc/html/atl.html ... -atl-block
2) Use Movie sprite backed by video of your animation:
https://www.renpy.org/doc/html/movie.ht ... ie-sprites
- hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Contact:
Re: Can I use animated GIF pictures?
images supported: https://www.renpy.org/doc/html/displayables.html#Image
You have many options here, either make them a Movie displayable (use webm and masking to simulate transparency)
or use DynamicDisplayable, as a substitute to ATL.
Below is a working code that I made before using a DynamicDisplayable.
now inside your images folder, you just have to put your images for the animation there, then you can manually specify the frames as shown above or just populate the frames yourself if the images' names have a known format (e.g. frame x, where x = number). So the naming of the images doesn't really matter.
You have many options here, either make them a Movie displayable (use webm and masking to simulate transparency)
or use ATL to animate the image frames manually.mask
If given, this should be the path to a movie file that is used as the alpha channel of this displayable. The movie file will be automatically played on movie_channel when the Movie is shown, and automatically stopped when the movie is hidden.
or use DynamicDisplayable, as a substitute to ATL.
Below is a working code that I made before using a DynamicDisplayable.
Code: Select all
init python:
def _animated_image_function(st, at, frames=[], interval=None):
if frames is None or len(frames) == 0: return Null(), None
frame_count = len(frames)
if interval is None:
interval = 1 / float(frame_count)
return frames[int((st // interval) % frame_count)], interval
def generate_frames(image_name_format, frame_range=range(30)):
return [image_name_format.format(i) for i in frame_range]
def AnimatedImage(frames, interval=1.0 / 30.0):
return DynamicDisplayable(
_animated_image_function,
frames,
interval
)
image animated image 1 = AnimatedImage(
["image frame 1", "image frame 2", "image frame 3"] # specify the image names as a list [...]
)
image animated image 2 = AnimatedImage(
generate_frames("frame {}", range(3, 30)), # use the function above to quickly populate frames using the given format... ["frame 3", "frame 4", ..., "frame 29"]
0.02 # you can also set the speed per frame, by default it is set to 1.0 / 30.0 (30 fps)
)
-
- Newbie
- Posts: 18
- Joined: Thu Jun 24, 2021 4:12 am
- Contact:
Re: Can I use animated GIF pictures?
Thank you very much!hell_oh_world wrote: ↑Mon Jul 19, 2021 6:02 am images supported: https://www.renpy.org/doc/html/displayables.html#Image
You have many options here, either make them a Movie displayable (use webm and masking to simulate transparency)or use ATL to animate the image frames manually.mask
If given, this should be the path to a movie file that is used as the alpha channel of this displayable. The movie file will be automatically played on movie_channel when the Movie is shown, and automatically stopped when the movie is hidden.
or use DynamicDisplayable, as a substitute to ATL.
Below is a working code that I made before using a DynamicDisplayable.now inside your images folder, you just have to put your images for the animation there, then you can manually specify the frames as shown above or just populate the frames yourself if the images' names have a known format (e.g. frame x, where x = number). So the naming of the images doesn't really matter.Code: Select all
init python: def _animated_image_function(st, at, frames=[], interval=None): if frames is None or len(frames) == 0: return Null(), None frame_count = len(frames) if interval is None: interval = 1 / float(frame_count) return frames[int((st // interval) % frame_count)], interval def generate_frames(image_name_format, frame_range=range(30)): return [image_name_format.format(i) for i in frame_range] def AnimatedImage(frames, interval=1.0 / 30.0): return DynamicDisplayable( _animated_image_function, frames, interval ) image animated image 1 = AnimatedImage( ["image frame 1", "image frame 2", "image frame 3"] # specify the image names as a list [...] ) image animated image 2 = AnimatedImage( generate_frames("frame {}", range(3, 30)), # use the function above to quickly populate frames using the given format... ["frame 3", "frame 4", ..., "frame 29"] 0.02 # you can also set the speed per frame, by default it is set to 1.0 / 30.0 (30 fps) )
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3794
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Can I use animated GIF pictures?
Note that mp4 video is not supported either.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Who is online
Users browsing this forum: Bing [Bot]