Animation

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
DevBoyLars
Posts: 216
Joined: Wed Feb 27, 2013 9:04 pm

Animation

Post by DevBoyLars » Sat Jan 24, 2015 10:54 am

Hello,
what is the best way to put animation in an App in LiveCode?

What I mean is something like that http://www.paintcodeapp.com, in section "Variables & Expressions", the roboter-arm such as.

SparkOut
Posts: 2862
Joined: Sun Sep 23, 2007 4:58 pm

Re: Animation

Post by SparkOut » Sat Jan 24, 2015 11:57 am

I can't find a section that shows a robot arm, only a pair of blocks that resize together and a circle that moves in a sine wave.
The connection between these expressions seems to be a use case in LiveCode for virtual custom properties. This is not the only way, and maybe not even the best, but you can use the getprop and setprop handlers to take action when dealing with property changes on one object affecting another.
For instance

Code: Select all

setProp cWideness pWidth
set the width of me to pWidth
set the left of me to 20
set the width of graphic "grcWide" to pWidth * 2
set the left of graphic "grcWide" to 20
end cWideness
A sample stack is zipped and attached to show how you can chain actions on multiple objects according to the setting of only one property on one object. Change the width selection slider and see how the width of the wide rectangle changes along with the small rectangle always in proportion. There is no code on the wide rectangle at all.

Because the setProp handler does not pass the message, the custom property cWideness (yes I just wanted to distinguish it from the built in width property) is not actually set on the small rectangle. Hence it is a "virtual custom property".
Attachments
virtual_custom_properties.livecode.zip
(759 Bytes) Downloaded 189 times

DevBoyLars
Posts: 216
Joined: Wed Feb 27, 2013 9:04 pm

Re: Animation

Post by DevBoyLars » Sat Jan 24, 2015 12:48 pm

This one :)
Attachments
Bildschirmfoto 2015-01-24 um 12.47.39.png

SparkOut
Posts: 2862
Joined: Sun Sep 23, 2007 4:58 pm

Re: Animation

Post by SparkOut » Sat Jan 24, 2015 1:02 pm

Well yes, the same principles apply. Set the virtual custom property of the "cAngle" and in the setProp cAngle handler you can get the passed parameter for that angle and use it to set the LargerAngle and any other angles according to the expression you define.

DevBoyLars
Posts: 216
Joined: Wed Feb 27, 2013 9:04 pm

Re: Animation

Post by DevBoyLars » Sat Jan 24, 2015 1:08 pm

Ok, so I've to "connect" all elements by myself in LifeCode, right?

SparkOut
Posts: 2862
Joined: Sun Sep 23, 2007 4:58 pm

Re: Animation

Post by SparkOut » Sat Jan 24, 2015 1:13 pm

Yes, as you do in paintcodeapp, but without a drag and drop interface.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”