Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How to clone an animation?

Author
Message
metamorpho
7
Years of Service
User Offline
Joined: 17th Oct 2016
Location: Planet Earth
Posted: 29th Apr 2019 10:24

fire=CreateSprite(LoadImage("fireanim.png")):SetSpriteAnimation(fire,64,64,16) :playsprite(fire,10,1,1,16)
SetSpritePosition( fire, xt, yt)
do
Sync()
loop

This code displays fire at the same time only in one place.

It is necessary to display three fire animations simultaneously.
What methods do you use?
What is the best way to do this?
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 29th Apr 2019 10:41
you only need to load the animation once
but you need a sprite instance for each one you want animated
if its only a temporary thing then you need some kind of loop
that deletes the old ones
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 29th Apr 2019 11:39
Just clone the first sprite

fire2 = CloneSprite(fire)
SetSpritePosition(fire2,x,y)

fire3 = CloneSprite(fire)
SetSpritePosition(fire3,x,y)

If the animation is already setup and playing on the first sprite then it will also be playing on the cloned ones too.
metamorpho
7
Years of Service
User Offline
Joined: 17th Oct 2016
Location: Planet Earth
Posted: 29th Apr 2019 18:18
fubarpk, Bengismo, thanks !!

Login to post a reply

Server time is: 2024-04-19 17:07:49
Your offset time is: 2024-04-19 17:07:49