Wallpaper Engine

Wallpaper Engine

View Stats:
nala May 23, 2021 @ 1:04pm
Play gif once on click?
I am trying to make an interactive wallpaper that plays a specific gif every time you click on it, but only plays one full loop of the gif per click. Is there a way I can do this?
< >
Showing 1-5 of 5 comments
Rhy May 23, 2021 @ 1:18pm 
There is a way using scripts.

You can locate the „on click“ snippet in the code editor. In that function you can play your gif using the play() function.
Inside the update you stop the animation when it reaches the last frame.

Here you can find more on scenescript: https://wallpaper-engine.fandom.com/wiki/Category:SceneScript
Last edited by Rhy; May 23, 2021 @ 1:19pm
Bruhsty May 23, 2021 @ 1:35pm 
You can try something like this, I haven't tried it and I wrote it on the phone, but should work.
'use strict'; let animation; export function update(value) { if (animation.isPlaying() && animation.getFrame() >= animation.frameCount()-1) { animation.stop(); } return value; } export function init() { animation = thisLayer.getTextureAnimation(); animation.stop(); } export function cursorClick(event) { if (!animation.isPlaying()) animation.play(); }
nala May 23, 2021 @ 1:39pm 
Originally posted by Ass Pancakes ||||| blw.tf:
There is a way using scripts.

You can locate the „on click“ snippet in the code editor. In that function you can play your gif using the play() function.
Inside the update you stop the animation when it reaches the last frame.

Here you can find more on scenescript: https://wallpaper-engine.fandom.com/wiki/Category:SceneScript
If I want to hide the gif or make it invisible after it is finished playing, how would I do so?
nala May 23, 2021 @ 1:43pm 
Originally posted by NotRusty:
You can try something like this, I haven't tried it and I wrote it on the phone, but should work.
'use strict'; let animation; export function update(value) { if (animation.isPlaying() && animation.getFrame() >= animation.frameCount()-1) { animation.stop(); } return value; } export function init() { animation = thisLayer.getTextureAnimation(); animation.stop(); } export function cursorClick(event) { if (!animation.isPlaying()) animation.play(); }
I have this part down, I just need a way to hide the gif after it is finished playing and then be able to show it again once the user clicks again. thisLayer.visible = false does not seem to work properly.
Bruhsty May 23, 2021 @ 1:49pm 
Originally posted by obipoketbobo:
Originally posted by NotRusty:
You can try something like this, I haven't tried it and I wrote it on the phone, but should work.
'use strict'; let animation; export function update(value) { if (animation.isPlaying() && animation.getFrame() >= animation.frameCount()-1) { animation.stop(); } return value; } export function init() { animation = thisLayer.getTextureAnimation(); animation.stop(); } export function cursorClick(event) { if (!animation.isPlaying()) animation.play(); }
I have this part down, I just need a way to hide the gif after it is finished playing and then be able to show it again once the user clicks again. thisLayer.visible = false does not seem to work properly.
In what way thisLayer.visible = false works improperly?
< >
Showing 1-5 of 5 comments
Per page: 1530 50

Date Posted: May 23, 2021 @ 1:04pm
Posts: 5