Newbie Sprite Animation Question

Another newbie question for those in the know:

I have a sprite as a default character defined as

self.model = "Dropbox:flapper_1" 

in a character class. How can I change that character sprite into another sprite (well actually two with a short delay, going back to the original sprite - no tweening necessary) when I use:

function touched(touch)
if touch.state == BEGAN and gameStart == true then

I have tried more scenarios than I care to admit without any success. A point in the right direction would be much appreciated. I hate to ask for what may be a simple solution but I am unclear of how to go about this personal dilemna.

Thanks for any help that you may provide. Any more details can be provided if necessary.

Hi @Keebo, I’m a newbie too. Have you checked the “Dungeon Roller” example included in Codea? It is used there some interaction between the hero, the player and the world. May be there you get the idea that you need.
Victor ~O)

I’m sure I have checked all examples and the ones included here but when you get my age memory sometimes is not you friend :slight_smile: . I will check the example you describe closer in hopes of getting closer to my goal.

Thank you my internet friend for a clue.

Try this

-- Use this function to perform your initial setup
function setup()
    print("Hello World!")
    anim=0 --a flag to state the current sprite image
    animmax=2 -- the number of sprite images
    animcount=0 --a counter for the delay between swapping images
    iparameter("animdelay",1,20,3) -- the length of delay hence speed of animation


-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    background(40, 40, 50)
    if anim==0 then
        sprite("Planet Cute:Gem Blue",WIDTH/2,HEIGHT/2)
    elseif anim==1 then
        sprite("Planet Cute:Gem Green",WIDTH/2,HEIGHT/2)
        sprite("Planet Cute:Gem Orange",WIDTH/2,HEIGHT/2)
    animcount = animcount + 1
    if animcount>animdelay then
        anim = anim + 1
    if anim>animmax then

@West, thank you for your example. While your code animates continuously and I needed to cycle through the anim only once on a tap event, it provided me a tremendous amount of help.

I was able to make some modifications, additions, and relocated it to fit my code to get the effect I was looking for. Another successful baby step accomplished :slight_smile: .

Now on to the dreaded pause/reset game issue.

Thanks again for your and quezadav’s help.

No probs -happy to help where I can