Optimizing and iOS Compatibility

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

Moderators: heatherlaine, kevinmiller, robinmiller, malte

Post Reply
Danny
Posts: 106
Joined: Tue Nov 09, 2010 1:28 am

Optimizing and iOS Compatibility

Post by Danny » Mon Apr 25, 2011 11:41 pm

Hello,
So I've been working on my app for quite awhile and like a lot of developers I neglected to watch how much code I was using and as a result it is extremely choppy and laggy. My game is simple: There are apples on a tree and they fall down the screen to an awaiting pig with a bucket. I have tried to optimize it but once you get to a higher level it just starts getting all choppy again. So a couple of questions...

1. Will Animation Engine work with iOS devices and be accepted by Apple so long as I follow their rules?

2. Before I buy AE I wanted to know if it could make my app run smoother? I posted some code so you know what I have currently...

Code: Select all

on initializeBalls
   local tBallCounter, tBallID, tStartHeight, tStartRight, tLoc
   lock screen
  
   -- delete any old balls
   if the number of items in gBallList > 0 then
      repeat for each item tBallID in gBallList
         try
            delete tBallID
            end try
      end repeat
   end if
   put empty into gBallList
   
   -- create the new apples
   put item 2 of the loc of grc "grcStartField" into tLoc
   repeat with tBallCounter = 1 to fld "fNumBalls"
# This clones one apple however many times I choose
      clone img "BallTemplate"
      put it into tBallID
      put tBallID & comma after gBallList
      set the width of tBallID to fld "fBallSize"
      set the height of tBallID to fld "fBallSize"
# This makes a "Box" of constraints 
    put random(220) + 10 & comma & random(200) + 20 into tLoc
    set the loc of img "BallTemplate" to tLoc
    
   end repeat
   delete the last char of gBallList
   
   unlock screen
end initializeBalls

on dropTheBalls
   local tTimeSpan, tBallID, tBallNum, tTempBallList
   lock screen
   put fld "fDropRate" into tTimeSpan
   put gBallList into tTempBallList
   unlock screen
   repeat the number of items in gBallList times
      put random(the number of items in tTempBallList) into tBallNum
      put item tBallNum of tTempBallList into tBallID
      send "dropMe" to tBallID in tTimeSpan seconds 
      delete item tBallNum of tTempBallList
      add fld "fDropRate" to tTimeSpan
   end repeat
end dropTheBalls
The thing is here is I feel like some serious code can be reworked to do the same thing.


And this is the script for the apples when they drop. I think that one of my problems is that this is run EVERY time an apple drops. I've wondered if there was a way you could make a central location that you could store you custom handler and then call it in the app any where you want.

Code: Select all

global gBucket

on dropMe
   local tXPos, tYTarget
   add 1 to fld "fBallsDropped"
   put item 1 of the loc of me into tXPos
   put item 2 of the loc of grc "grcBucketField" into tYTarget
   move me to tXPos,tYTarget without waiting  
   set the layer of img "BallTemplate" to bottom
end dropMe

on moveStopped
   if pointIntersect(the loc of me,the rect of img "Pig") then 
      add 1 to fld "fBallsCaught"
      add 1 to fld "fBallsCaught2"
      hide me
      play specialFolderPath("engine") & "/soundFormats/bite.aif"
   end if
   hide me
end moveStopped

function pointIntersect pPoint,pRect
   split pPoint by comma
   split pRect by comma
   return ((pRect[1] <= pPoint[1]) and (pPoint[1] <= pRect[3]) and (pRect[2] <= pPoint[2]) and (pPoint[2] <= pRect[4]))
end pointIntersect
I do want to make sure I'm clear that I don't need any body to take their time to optimize this code, but that would be ok if you want to :lol: . I just want to know of some AE commands, and some sample code would be nice, that could do this better and smoother.

Thank you for taking the time to read it. I know it's a long post but I know you'd probably ask for sample code anyway.

Crossing my fingers,
Danny

Danny
Posts: 106
Joined: Tue Nov 09, 2010 1:28 am

Re: Optimizing and iOS Compatibility

Post by Danny » Tue May 03, 2011 7:23 pm

Anybody?

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Re: Optimizing and iOS Compatibility

Post by BvG » Tue May 03, 2011 7:55 pm

there's a demo version of AE, so why don't you simply try it out?
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Danny
Posts: 106
Joined: Tue Nov 09, 2010 1:28 am

Re: Optimizing and iOS Compatibility

Post by Danny » Tue May 03, 2011 7:59 pm

I actually have been but I saw that you can't use it in development mode. I thought that meant you can't test it on your iPod and I need to test it on that because the simulator is deceiving. Maybe i'm wrong?

Danny

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Re: Optimizing and iOS Compatibility

Post by BvG » Wed May 04, 2011 12:18 am

Well but your question is mostly about it's usefulness to your approach of animation, and i think no one but yourself can actually answer that :)

The first question was, if it runs at all on iOS, so i guess i can answer that it does.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Optimizing and iOS Compatibility

Post by malte » Wed May 04, 2011 6:21 am

Danny wrote:I actually have been but I saw that you can't use it in development mode. I thought that meant you can't test it on your iPod and I need to test it on that because the simulator is deceiving. Maybe i'm wrong?

Danny
Hi Danny,

where did you see that?

The trial version is fully functional for 15 sessions (means start using stack "animationEngine"). So if you start using animationEngine once and do not shut down your development environment, in theory you can try it there forever before you need to make the decision if it is useful enough or not. A compile removes the libraries in use in the IDE though if I recall correctly, so once you transfer it to the simulator and / or device, you will have to start a new session with start using.

Hope that helps,

Malte

Post Reply

Return to “Animation Engine”