Transform not updating? (in python)

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
Dengar
Newbie
Posts: 3
Joined: Tue Sep 19, 2017 11:09 am
Contact:

Transform not updating? (in python)

#1 Post by Dengar »

I'll just get right to the point:

Code: Select all

init python:
	trans = Transform("image.png")
	trans.rotate = 90.0
	trans.update()
	
image immy = trans

label start:

	scene bg place
	
	show immy
While it shows immy, the transform isn't rotated at all.

It works if I send rotate=90.0 as part of the constructor, but it seems changing the value later does nothing, even when calling update(). Am I doing something wrong?

I'm trying to create motion through python rather than ATL, so it's kind of important that I'm able to update a transform in real time. Do I have no choice other than to just create a whole new transform every update?

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Transform not updating? (in python)

#2 Post by Remix »

You might want to go with using an ATL python function and directly setting the motion variables as attributes of the Transform object contained within...

Basic example using rotate

Code: Select all

image solid_image:
    size(1,11)
    Solid("#c00")

init python:
    def py_transform(trans, st, at):
        trans.rotate = int( st * 5 )
        # this basically says recall the function as soon as possible
        return 0


label start:
    "First Line"
    show solid_image:
        pos (500, 300)
        function py_transform
    "Last Line"
The trans parameter of the python ATL function is basically a transform object that accepts positional and other attributes that affect the child displayable. Though it can (and probably will) create child transforms, any change to the 'trans' within the function should be quite visible on screen.
If you 'return None' it will stop the function for that displayable, return float sets the seconds until recall - e.g. return 0.05 would be 20 frames per sec (ish)
All movement, rotation, distortion and other alterations such as tinting should be doable with a little tinkering
Frameworks & Scriptlets:

Dengar
Newbie
Posts: 3
Joined: Tue Sep 19, 2017 11:09 am
Contact:

Re: Transform not updating? (in python)

#3 Post by Dengar »

That won't work for me. It has to be python.

Post Reply

Who is online

Users browsing this forum: Google [Bot], henne, Ocelot, snotwurm