[SOLVED] Spritesheet Support?

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: 373
Joined: Fri Sep 02, 2016 3:14 am
Completed: Multiverse Heroes, Space Hamster in Turmoil
Location: Puerto Rico
Contact:

[SOLVED] Spritesheet Support?

#1 Post by SypherZent »

Hello,

Sorry if this has been asked, it's just that I have found a number of different things on the topic.

Is there an efficient and simple way of using a spritesheet to animate one or more characters in Ren'Py?
Note that the spritesheet will have a custom format.

I don't want the game to have poor performance if I have 10-15 characters on screen.

Any help on the topic would be appreciated. Thanks!
Last edited by SypherZent on Sat Jan 07, 2017 11:41 pm, edited 1 time in total.
Creator of Multiverse Heroes & Space Hamster in Turmoil

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

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Spritesheet Support?

#2 Post by Divona »

Check out LiveCrop.
Completed:
Image

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Spritesheet Support?

#3 Post by nyaatrap »

The most straight forward way is:

Code: Select all

image spriteX:
    "sheetX.png"
    crop (0,0,width,height)
    pause 1.0/framerate
    crop (0,1*height, width, height)
    pause 1.0/framerate
Though it's very redundant way of coding.
There're some other ways to code more efficiently. One example code I'm using is:

Code: Select all

init pyton:
        def draw_effect(st, at, image_path, last_frame, width=360, height=360, framerate=24):            
            # Retruns a Filmstrip displayable
            
            number=int(st*framerate)
            if number < last_frame:
                return Transform("gfx/{}.png".format(image_path), crop=(0,height*number,width,height)), 1.0/framerate
            else:
                return Null(), None

        renpy.image(effect, DynamicDisplayable(draw_effect, image_path, last_frame))

User avatar
SypherZent
Veteran
Posts: 373
Joined: Fri Sep 02, 2016 3:14 am
Completed: Multiverse Heroes, Space Hamster in Turmoil
Location: Puerto Rico
Contact:

Re: Spritesheet Support?

#4 Post by SypherZent »

Aha! Much simpler than I thought.
Excellent, thank you! Both examples are straightforward and helpful.

Will also take a peek at LiveCrop to see if I can use it.

Thanks for the quick replies!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], pockatuck