Help with a few effects (if possible)

Hi guys,

First of all, a MASSIVE thank you to Peaches. I started using Corona last week to create a simple kids book, and without her help, I would have never have got as far with my project as I have.

The app is now completed, however, I want to add in a couple of elements to make the user experience a little more fun.

Basically, the two elements I would love to add are:

1: If the user touches and moves their finger around the screen, stars will appear at the touch area and follow your finger until you release your touch.
2: On the screen there will be a little star that will move (or grow then shrink) if you touch it.

Thats it really, I’ve had a look through quite a few sites, and cant seem to find examples, so, I would really appreciate any help/advise you all may have.

Thanks again everyone, I’m really loving Corona, and all your help makes it even better.

Have a great weekend,

Chris [import]uid: 43642 topic_id: 24850 reply_id: 324850[/import]

Hey Chris, thanks so much for the shoutout :slight_smile:

This code is a bit rough but it’s plug and play so you can run it on its own and see if it suits you for your star drawing functionality;
[lua]local bg = display.newRect( 0, 0, 320, 480 )
bg:setFillColor(0, 0, 0)

local star = {}

local function drawStars(event)
starX, starY = event.x, event.y
if event.phase == “began” then
starTimer = timer.performWithDelay(100,
function()
star[#star+1] = display.newCircle( starX, starY, 10)
transition.to(star[#star], {time=1000, alpha=0})
end,
0 )
elseif event.phase == “ended” or event.phase == “cancelled” then
timer.cancel(starTimer)
end
end
bg:addEventListener(“touch”, drawStars)[/lua]

Obviously I’m using circles there.

You’d also want to make sure you put them in your localGroup (if using director) as they aren’t being cleaned up currently.

For the growing/shrinking, try something like this, also plug and play;
[lua]local circ = display.newCircle( 160, 200, 20 )

local function touchCirc (event)
transition.to(circ, {time=1000, xScale=2, yScale=2, onComplete=function()transition.to(circ,{time=1000, xScale=1, yScale=1})end})
end
circ:addEventListener(“tap”, touchCirc)[/lua]

Hope this helps!

Peach :slight_smile: [import]uid: 52491 topic_id: 24850 reply_id: 100965[/import]