No wait command on Android?

The place to discuss anything and everything about running your LiveCode on Android

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
ace16vitamine
Posts: 97
Joined: Fri Apr 13, 2018 1:53 pm

No wait command on Android?

Post by ace16vitamine » Sun Sep 06, 2020 7:23 pm

Dear all,

some days ago I startet a Topic "Hamburger Menue" in the iOS section. I started to create a slider menue (means that a component moves from the left site to the right site after pressing a menue button.

On iOS it is working perfect! No issues, the components are moving from left to right and I can setup the speed with "wait" and the steps.

But on Android... the slider is slow.And it doest care if i wait 0.01 sec, wait 0.001 sec or if I delete the complete Line. It is: slow... And it is not the Hardware, I have the same issue on the Android Simulator.

Code: Select all

         
         #1 Calculate the display size
         put item 3 of the screenrect into cright
         
         # Create 20 Steps
         put cright / 20 into laenge 
         
         #the factor for moving
         put laenge into laenge_berechnung
         
        # to stop the slider
         put cright / 3 into crighthalb 
         
               repeat 20 times
                  
                  set the right of graphic "menu" to laenge
                  set the right of field "fldmenue" to laenge 
                  set the right of widget "menueheader" to laenge 
         
         # AND THIS wait is not working_
                  wait 0.01 sec
                  add laenge_berechnung to laenge
                  
end repeat


Any Ideas why?

Stefan

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5836
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: No wait command on Android?

Post by jacque » Mon Sep 07, 2020 8:20 pm

Andoid does support the wait command, but the method you've used isn't optimized enough for it to be seen. A wait of a second or more would probably be noticeable, but that isn't what you want.

I can think of three ways to do a slide-out panel:
1. Use the "move" command
2. Use visual effects
3. Use your step method with acceleratedRendering

All of these would benefit from using a group, so the first thing is to group the three controls. The group should be in the topmost layer on the card.

Using the "move" command:
------------------------------
Determine the final x,y positions of the group. Then:

Code: Select all

move group tGrp to x,y in 0.5 seconds -- adjust timing here
See the "move" entry in the dictionary for other options, like relative positioning.

When hiding the group, use the move command to slide the group offscreen to the left.

Using visual effects:
-------------------------
This is probably the simplest way. Position the group in its slide-out position. Lock the screen in the rect of the group. Hide (or show) the group, and unlock the screen with a visual effect.

Code: Select all

lock screen for visual effect in rect (the rect of group tGrp)
set the visible of group tGrp to not the visible of tGrp
if the vis of group tGrp then put "reveal left" into tEffect
else put "reveal right" into tEffect
unlock screen with visual effect tEffect
Step method with acceleratedRendering
------------------------------------------------
LiveCode's acceleratedRendering is designed to make smooth, fast animations for moving objects. All moving objects should have their layermode set to "dynamic" -- in this case, the group's layermode should be set. You can set the layermode in the property inspector. That tells LC that this control needs to be cached in memory and redrawn quickly. Somewhere in your code, set the acceleratedRendering of the stack to true. If you only need it on one card, you can do that in a preOpenCard handler; if you need it on several cards, do it in a preOpenStack handler. Once acceleratedRendering is true and the group's layermode is set to dynamic, your original step method should respond faster provided you move the group and not its individual objects.

Depending on the user's device, you will not get consistent results with this method, it all depends on the CPU and the graphics card in the device. Personally I'd use one of the other two methods.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

ace16vitamine
Posts: 97
Joined: Fri Apr 13, 2018 1:53 pm

Re: No wait command on Android?

Post by ace16vitamine » Tue Sep 08, 2020 11:57 am

Thank you for your explantation Jacqueline :-)

The move command ist perfect.

Post Reply

Return to “Android Deployment”