Optimisation for simultaneous AE calls

Create fast, sprite powered games with Animation Engine, co-developed with DerBrill Software!

Moderators: heatherlaine, kevinmiller, robinmiller, malte

Post Reply
donbrae
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 19
Joined: Sun Feb 22, 2009 9:49 pm
Location: Edinburgh, Scotland, UK
Contact:

Optimisation for simultaneous AE calls

Post by donbrae » Sun Feb 02, 2014 12:57 pm

Hey,

I'm experiencing a drop in frame rate when performing two AE animations simultaneously. Here's an example of code I'm using to create an effect of on-screen elements "evaporating":

Code: Select all

aeLockMoves
aeMoveTo the long id of group "app_controls", item 1 of the loc of this card, tStartingPoint, 350 -- Move controls up
aeFadeOut the long id of group "app_controls", 300 -- Fade controls out
aeUnlockMoves
I've played around with the frame rate (setting it to anywhere between 30 and 100) but the "juddery-ness" persists. All elements in the group have their Layer Mode set to Dynamic, and have their size and position locked.

It tends to be slightly better in the simulator but is really noticeable on my 5s.

Before I go digging into the AE code a bit more, I thought I'd check whether anyone here has experienced and overcome this issue already?

Many thanks,

Jamie
Jamie Smith
Composer, web dev, LiveCoder
www.donbrae.co.uk - Donbrae Studios: Music for games, film, TV, web
jamieonkeys.tumblr.com - My game development blog

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: Optimisation for simultaneous AE calls

Post by dave.kilroy » Sun Feb 02, 2014 3:22 pm

Hi Jamie

Yes I had a similar issue (moving a group containing quite a few controls) and what I did in the end was to take a snapshot of the group prior to moving, move the snapshot image with AE, and once it had reached it's final position I'd move the group into place under the image and finally delete the snapshot

Maybe you or someone else can come up with a better way (I'd love to hear it) but that was the only way I could get round a slight 'judder' on moving the group on an app for iPads

Dave
"...this is not the code you are looking for..."

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: Optimisation for simultaneous AE calls

Post by dave.kilroy » Sun Feb 02, 2014 3:24 pm

Also, I found that simply resetting the blend level in a repeat loop gave better performance than aeFadeOut...
"...this is not the code you are looking for..."

donbrae
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 19
Joined: Sun Feb 22, 2009 9:49 pm
Location: Edinburgh, Scotland, UK
Contact:

Re: Optimisation for simultaneous AE calls

Post by donbrae » Mon Feb 03, 2014 8:12 pm

Many thanks, Dave. Will go ahead and try animating a snapshot.
Jamie Smith
Composer, web dev, LiveCoder
www.donbrae.co.uk - Donbrae Studios: Music for games, film, TV, web
jamieonkeys.tumblr.com - My game development blog

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: Optimisation for simultaneous AE calls

Post by dave.kilroy » Mon Feb 03, 2014 11:16 pm

Hi Jamie - this is the guts of how I arrange the snapshot stuff...

What I'm moving is a group which acts as the basis for a scroller (made up of 52 fields and 52 images - and depending on user play/progress up to a further 52 smaller images) - I also have a button (an image) which usually sits on the edge of the iPad screen and the user presses to slide the scroller out into view and later on can be pressed again to slide the scroller away out of sight

So I'm moving the group plus the button image plus the scroller itself (I delete it once it is out of sight and recreate it when the scroller is next called)

First from the image button's mouseUp handler I call the swapImage handler to take a screenshot of the current state of the scroller and the group behind it and put the name of this new image into sReplacementImage. Back in the mouseUp I then use aeMoveTo to move the snapshot and button image - and if I'm moving the scroller out into view get the scrollerPanelExtended handler to call itself every quarter second to see if it has reached its fully open position - if it has then I move the group and scroller out to be under the snapshot and then delete the snapshot leaving a functioning scroller in it's place.

If the scroller is in the open position and it is being called to slide out of view the process is similar except this time I get the scrollerPanelHidden to check whether it is fully hidden - and then deal with tidying up...

I have other handlers that create and recreate the scroller, make sure the controls in the group are properly positioned and contain the correct text, image files etc but the 'meat-and-potatoes' of the image substitution is in the following three handlers:

Code: Select all

on swapImage
   lock screen
   import snapshot from grp "grpScrlGames" of grp "grpScrollerModule"
   
   if gHideScroller = true then--scroller is hidden, about to come out
      set the name of the last img to "imgHiddenGoingToSlideOut"
      put "imgHiddenGoingToSlideOut" into sReplacementImage
   else--scroller is out, about to slide in
      set the name of the last img to "imgOutGoingToSlideIn"
      put "imgOutGoingToSlideIn" into sReplacementImage
   end if
   
   set the loc of img sReplacementImage to the loc of grp "grpScrlGames"
   unlock screen
end swapImage


on scrollerPanelExtended
   put item 1 of the loc of image "imgShowHideSlider" of group "grpScrollerModule" into tLeft
   put item 1 of gLocShowHideScrollerShow into tLeft2
   
   --once scroller panel is fully extended change the button to 'up' status
   if tleft < tLeft2 then
      send scrollerPanelExtended to me in 250 millisecs
   else
      lock screen
      set the filename of image "imgShowHideSlider" of this card to "images/buttons/" & sImgNameUp
      set the loc of grp "grpScrlGames" to the loc of the last image
      delete img sReplacementImage--the last image
      show grp "grpScrlGames"
      put empty into sMouseUp
      unlock screen
   end if
end scrollerPanelExtended


on scrollerPanelHidden
   put item 1 of the loc of the last image into tLeft
   put item 1 of gLocgrpScrlGamesHide into tLeft2
   
   --once scroller panel is fully hidden change the button to 'up' status
   if tleft > tLeft2 then
      send scrollerPanelHidden to me in 250 millisecs
   else
      set the loc of grp "grpScrlGames" to gLocgrpScrlGamesHide
      set the filename of image "imgShowHideSlider" of this card to "images/buttons/" & sImgNameUp
      
      set the vscroll of group grpScrlGames to 0
      
      put the short name of the last image into tN
      if tN <> "imgGettingStarted" then
         delete img sReplacementImage--the last image
      end if
      put empty into sMouseUp
   end if
end scrollerPanelHidden
I'd be really interested to hear how you get on - and of course if anyone has suggestions for improving my lashed-together code I'd be delighted to read that too :)

Kind regards

Dave
"...this is not the code you are looking for..."

Post Reply

Return to “Animation Engine”