transition not working

I have a simple flashing box to alert someone when a timer is almost expired and it worked very well, but then I decided I needed to add another item to flash along with it.

local topRedAlertRectAngled = display.newRect( group, 0, 0, 0, 0 )  
topRedAlertRectAngled.x = settingsRect.x-99  
topRedAlertRectAngled.y = settingsRect.y+99  
topRedAlertRectAngled.width = settingsRect.width \* .8  
topRedAlertRectAngled.height = settingsRect.height \* 1.015  
topRedAlertRectAngled.rotation = 45  
topRedAlertRectAngled.strokeWidth = 3  
topRedAlertRectAngled:setFillColor(0,0,0,0)  
topRedAlertRectAngled:setStrokeColor(255, 255, 255,255)  
topRedAlertRectAngled.alpha = 0  
  
local topRedAlertRect = display.newRect( group, 0, 0, (otherRect.width \* .9), (otherRect.height \* .9) )  
topRedAlertRect.x = topRedRect.x  
topRedAlertRect.y = topRedRect.y  
topRedAlertRect.strokeWidth = 3  
topRedAlertRect:setFillColor(0,0,0, 0)  
topRedAlertRect:setStrokeColor(255, 255, 255)  
topRedAlertRect.alpha = 0  
  
local function flashTopRedAlert(theRect, theAngledRect)  
 local function printMessage()  
 print("red transition done")  
 end  
  
 local function revertFlash()  
  
 transition.to(theAngledRect, { time = 750, alpha = 0, transition = easingx.easeIn, onComplete = printMessage})  
 transition.to(theRect, { time = 750, alpha = 0, transition = easingx.easeIn, onComplete = flashTopRedAlert })  
 end  
  
  
  
 if(keepTopRedRunning == 1)  
 then  
 transition.to(theAngledRect, { time = 750, alpha = 1, transition = easingx.easeIn, onComplete = printMessage})  
 transition.to(theRect, { time = 750, alpha = 1, transition = easingx.easeIn, onComplete = revertFlash })   
 end  
end  
  

The transition on “theRect” works perfectly and repeatedly until “keepTopRedRunning” is turned off. The strange part is that the transitions on “theAngledRect” fire the first time for both of the transitions, but then don’t fire again.

I tried adding the two rects to a display group and transitioning the alpha of the display group, but that didn’t work at all (is transitioning the alpha of a display group not possible?). I confirmed that the transitions were working by transitioning the groups x coordinate. It moved around, but the alpha didn’t change.

I’d be happy to do it either way (two transitions or one transition on a display group). If anyone has any advice or a fix for this I’d be greatly appreciative. Thanks! [import]uid: 39480 topic_id: 21589 reply_id: 321589[/import]

Any chance of plug and play? :slight_smile: [import]uid: 52491 topic_id: 21589 reply_id: 85759[/import]

What do you mean by plug and play? Would a quick sample app help? Thanks Peach :slight_smile: [import]uid: 39480 topic_id: 21589 reply_id: 85801[/import]

Peach,

I uploaded a sample project for you to try. I assume that’s what you mean by plug and play.

Link: http://db.tt/nYBm2Tk5

In that sample you click the blue button which calls a method that flashes two rects that have no fill color, but a white border. If you look in the “sceneTemplate.lua” file there are comments there to explain the two methods I tried to get the alpha transitions to work.

If I can answer any questions that would help please let me know. Thanks so much for your help! [import]uid: 39480 topic_id: 21589 reply_id: 85833[/import]

Hey Tim,

Plug and play can be either a downloadable sample as you’ve provided or code that I can copy and paste then run because it relies on no other classes, images or sounds - so, thank you :slight_smile:

I have taken a look and you’re right, it isn’t working correctly.

There are a few ways I considered to tackle this but the easiest is to place the two rects in a group.

Before adding them;
[lua]local rectGroup = display.newGroup()[/lua]
After adding them;
[lua]rectGroup:insert(topRedAlertRectAngled)
rectGroup:insert(topRedAlertRect)[/lua]
When defining the function;
[lua]local function flashTopRedAlert(theRect)[/lua]
When calling the function;
[lua]flashTopRedAlert(rectGroup)[/lua]

And comment out the two lines within that function relating to transitioning the angled rect.

Does this help?

Peach :slight_smile: [import]uid: 52491 topic_id: 21589 reply_id: 86085[/import]

Peach,

I really appreciate your continued replies on this issue. I love the support from Corona!

I had that same idea and tried it and, in fact, if you look at the sample code I had two versions of the code. One had the rects being added to the normal “group”, but the other was adding them to “flashGroup” and I was calling the transition on the flashGroup. It works if the rects start with an alpha of 1, but not when you start them at zero, which is what I need.

Just to be sure I changed my sample project to implement it with your changes. Would you try it out for me please? Thanks!

Sample Project Link: http://dl.dropbox.com/u/25267244/Sample_Project%202%20021012.zip [import]uid: 39480 topic_id: 21589 reply_id: 86098[/import]

I understand - download and run this; http://techority.com/trashThis.zip

I modified group alpha while spawning squares at alpha = 1. (You don’t see them, the groups alpha is set immediately.)

I left in some print statements I was using to check stuff so if you see “X”, “y” and/or “z” print, I apologize in advance :wink:

Let me know how that goes - and kindly forgive the zip name, just reminding myself to trash it after. (Techority is a bit of a space hog.)

Peach :slight_smile: [import]uid: 52491 topic_id: 21589 reply_id: 86126[/import]

Peach,

Thank you so much. I did not know that a group could have it’s own alpha. When I was doing the transition on the group I thought I was transitioning the rects’ alphas and not the group’s alpha. I’m so glad to have learned this not just for this issue, but knowing this about groups will be great for the future.

Thanks again, Peach. So glad you guys are so involved with helping your community. [import]uid: 39480 topic_id: 21589 reply_id: 86145[/import]

Not a problem at all Tim - my apologies, I should have perhaps given you a run down on groups.

They can be transitioned, removed, moved, faded out, faded in - lots of neat stuff, really.

I’m glad we’re so involved with helping our community too - it’s the most important thing I do each day and without it I’d be very, very bored :wink:

Peach :slight_smile: [import]uid: 52491 topic_id: 21589 reply_id: 86271[/import]