App speed up

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
itay1023
Posts: 68
Joined: Fri Sep 28, 2012 1:44 pm

App speed up

Post by itay1023 » Sat Nov 30, 2013 11:40 am

Hi,
I am buildong a game for iOS platform.
When i tested it on my iOS device, the game worked slow....
Can someone give my a code or something that will speed up my game?

Best regards,
Itay

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: App speed up

Post by jmburnod » Sat Nov 30, 2013 6:58 pm

Hi Itay,

Did you use acceleraterendering ?

Best regards
Jean-Marc
https://alternatic.ch

itay1023
Posts: 68
Joined: Fri Sep 28, 2012 1:44 pm

Re: App speed up

Post by itay1023 » Sun Dec 01, 2013 10:10 am

Yes, but it still works slow.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: App speed up

Post by Simon » Sun Dec 01, 2013 10:36 am

Hi itay1023,
I've seen that you have posted a few questions that you've not received a reply to.
It's best if you showed code to what you have tried, and a description of what you are trying to do with examples.

Yep... scorlling a 24 MB image will be slow... is that what you are doing?

You see? I can keep asking question like that for about... ummm 20 seconds then I don't want to play guessing games any more.

Would you like help?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

itay1023
Posts: 68
Joined: Fri Sep 28, 2012 1:44 pm

Re: App speed up

Post by itay1023 » Sun Dec 01, 2013 10:50 am

Yes, i do.

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: App speed up

Post by Jellicle » Sun Dec 01, 2013 11:34 am

itay1023 wrote:Yes, i do.
Then show us your code.

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

itay1023
Posts: 68
Joined: Fri Sep 28, 2012 1:44 pm

Re: App speed up

Post by itay1023 » Sun Dec 01, 2013 11:46 am

That's the image code:
local LocVar
global _life
global _startTheGame
global _score
global blackVar

on mouseDown
if _startTheGame is true then
put the loc of me into LocVar
grab me
send theButtonVar to me
end if
end mouseDown

on mouseUp
set the loc of me to LocVar
end mouseUp


on theButtonVar
if intersect (btn "theButton" of card "gameCardNew", button "blueBubble" of card "gameCardNew", 50) then
hide button "blueBubble" with visual effect dissolve fast
set the loc of btn "blueBubble" to 581,269
add 10 to _score
put _score into fld "score" of this card
hide btn "blueBubble"
send theButtonVar2 to me in 0.001 seconds
else
send theButtonVar2 to me in 0.001 seconds
end if
end theButtonVar

on theButtonVar2
if intersect (btn "theButton" of card "gameCardNew", button "redBubble" of card "gameCardNew", 50) then
add -1 to _life
put _life into fld "life"
hide button "redBubble"
set the loc of btn "redBubble" to 581,269
SavedRedBubbleActions
send theButtonVar3 to me in 0.001 seconds
else
send theButtonVar3 to me in 0.001 seconds
end if
end theButtonVar2

on theButtonVar3
if intersect (btn "theButton" of card "gameCardNew", button "goldBubble" of card "gameCardNew", 50) then
add 100 to _score
put _score into fld "score"
hide btn "goldBubble" of card "gameCardNew"
set the loc of btn "goldBubble" to 581,269
send theButtonVar4 to me in 0.001 seconds
else
send theButtonVar4 to me in 0.001 seconds
end if
end theButtonVar3

on theButtonVar4
if intersect (btn "theButton" of card "gameCardNew", button "blackBubble" of card "gameCardNew", 50) then
add -50 to _score
hide btn "blackBubble"
set the loc of btn "blackBubble" to 581,269
put _score into fld "score"
send theButtonVar5 to me in 0.001 seconds
else
send theButtonVar5 to me in 0.001 seconds
end if
end theButtonVar4

on theButtonVar5
if intersect (btn "theButton" of card "gameCardNew", btn "heartBubble" of card "gameCardNew", 50) then
add 1 to _life
put _life into fld "life" of card "gameCardNew"
hide btn "heartBubble" of card "gameCardNew"
set the loc of btn "heartBubble" to 581,269
send theButtonVar to me in 0.001 seconds
else
send theButtonVar to me in 0.001 seconds
end if
end theButtonVar5

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: App speed up

Post by Klaus » Sun Dec 01, 2013 2:09 pm

Hi Itay,

you are sending your messages in a too short intervall and end up with 5 commands per millisecond!
And you do not stop checking at any point!?
That will surely slow down everything to a still life 8)

Try this and check my comments:

Code: Select all

local LocVar
global _life

## Store the ID of the last SEND in a variable, so you can CANCEL it on "mouseup"!
## No need to check when the mouseis '"UP", right?
local tMessageID

global _startTheGame
global _score
global blackVar

on mouseDown
  if _startTheGame =FALSE then
    exit mousedown
  end if
  put the loc of me into LocVar
  grab me

  ## Since this is ONE part of your complete "Collision detection" routine it should be called immaediately!
  ## No need to send it here.
  theButtonVar
end mouseDown

on mouseUp
  set the loc of me to LocVar

  ## Now cancel the last SEND!
  cancel tMessageID
end mouseUp

on theButtonVar
  if intersect (btn "theButton" of card "gameCardNew", button "blueBubble" of card "gameCardNew", 50) then

   ## A visual effect will also slow down things!
   ## NOTHING will happen during the effect!
   ## So maybe you wnat ot comment this out?
    hide button "blueBubble" ## with visual effect dissolve fast
    set the loc of btn "blueBubble" to 581,269
    add 10 to _score
    put _score into fld "score" of this card
    hide btn "blueBubble"
  end if

  ## See above...
  theButtonVar2
end theButtonVar

on theButtonVar2
  if intersect (btn "theButton" of card "gameCardNew", button "redBubble" of card "gameCardNew", 50) then
    add -1 to _life
    put _life into fld "life"
    hide button "redBubble"
    set the loc of btn "redBubble" to 581,269
    SavedRedBubbleActions
  end if

  ## See above...
 theButtonVar3
end theButtonVar2

on theButtonVar3
  if intersect (btn "theButton" of card "gameCardNew", button "goldBubble" of card "gameCardNew", 50) then
    add 100 to _score
    put _score into fld "score"
    hide btn "goldBubble" of card "gameCardNew"
    set the loc of btn "goldBubble" to 581,269
  end if
  theButtonVar4
end theButtonVar3

on theButtonVar4
  if intersect (btn "theButton" of card "gameCardNew", button "blackBubble" of card "gameCardNew", 50) then
    add -50 to _score
    hide btn "blackBubble"
    set the loc of btn "blackBubble" to 581,269
    put _score into fld "score"
  end if
  theButtonVar5
end theButtonVar4

on theButtonVar5
  if intersect (btn "theButton" of card "gameCardNew", btn "heartBubble" of card "gameCardNew", 50) then
    add 1 to _life
    put _life into fld "life" of card "gameCardNew"
    hide btn "heartBubble" of card "gameCardNew"
    set the loc of btn "heartBubble" to 581,269
  end if
  
  ## NOW send your routines in a short interval:
  ## hte message you want ot send in QUOTES!
  send "theButtonVar" to me in 100 millisecs

 ## STORE messages ID:
  put the result into  tMessageID 
end theButtonVar5
Best

Klaus

Post Reply