Blinking Eyes (or swapping images in general)

In this case I’m working with 2 images, positioned on top of each other.
The image on top is the open eyeball image. The closed eyeball image is underneith, and not visible either:


local toonBGeyes1 = display.newImageRect(“toons/eye_closed.png”, 310, 442);
toonBGeyes1:setReferencePoint(display.BottomLeftReferencePoint);
toonBGeyes1.x = 0;
toonBGeyes1.y = _H;
toonBGeyes1.isVisible = false;

local toonBGeyes2 = display.newImageRect(“toons/eye_opened.png”, 310, 442);
toonBGeyes2:setReferencePoint(display.BottomLeftReferencePoint);
toonBGeyes2.x = 0;
toonBGeyes2.y = _H;
toonBGeyes2.isVisible = true;

local function blinkEyes()
–show image, hide image
toonBGeyes2.isVisible = false;
toonBGeyes1.isVisible = true;

toonBGeyes1.isVisible = false;
toonBGeyes2.isVisible = true;

end

tmr = timer.performWithDelay(3000, blinkEyes, -1);

I know this is a horrible way to swap an image with another, and I admit it. I very new to Lua, and I just downloaded Corona today. I’m having tons of fun with it.

I seriously need a little better direction with animating the blinking of eyes.

Any better ideas out there? [import]uid: 154122 topic_id: 27152 reply_id: 327152[/import]

Hey there,

You should use a sprite sheet :slight_smile: (Do you want more info on that? I’m not sure if you’ve already looked into it or not.)

As to the above - is that working? I don’t see an “if” statement and can’t quite picture the setup. Is that one for each eye? Or two sets of eyes, one open, one closed?

Peach :slight_smile: [import]uid: 52491 topic_id: 27152 reply_id: 110247[/import]