(Solved) Preloading Cropped Images

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
User avatar
SypherZent
Veteran
Posts: 362
Joined: Fri Sep 02, 2016 3:14 am
Completed: Multiverse Heroes, Space Hamster in Turmoil
Location: Puerto Rico
Contact:

(Solved) Preloading Cropped Images

#1 Post by SypherZent »

Is it possible to preload cropped images?

I use large spritesheets and crop frames with Python.
However, the sprite always lags on the very first playback, since it hasn't preloaded the cropped frames.
I tried using renpy.predict on every frame, but that did not work.
Once the animation has run the first time, it doesn't lag anymore.

Up until now, my solution has been to run the animation off the screen the first time around.
However, that is lagging text and showing of sprites in game, so I've had to create a Loading screen.

Now, I want to eliminate Loading altogether.
So, is there any way to preload sprites without having to lag the game and play them through?

---

Found a solution.

Code: Select all

renpy.cache_pin('spritesheet.png')
By using renpy.cache_pin on every spritesheet (rather than the cropped frames) that will appear in selected stage, the first playback is much faster and the loading time is significantly reduced (from 10 seconds down to about 1.5 seconds). RAM jumps a bit (from 135 MB to 235 MB), but it is a much better solution than the loading or lag felt by trying to force first playback of every cropped frame.
Creator of Multiverse Heroes & Space Hamster in Turmoil

Want me to code your game?
Check my services thread!

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot]