This section gives an illustrative example of using an animation bitmap. Settings may differ depending on your project’s configuration. |
Exercise: Playing an animation bitmap object
The following example displays a conveyor belt which carries a box. The conveyor animation plays only when it is turned on by a button.
a) Create two tags: a digital tag for controlling the conveyor belt and an analog tag for controlling the box position. Name the tags “CONVEYOR” AND “BOX”, respectively.
b) Go to [Edit] – [Insert Animation Bitmap] and select a conveyor object. Insert 2 conveyor objects into the graphic page.
c) Configure the tags for both conveyor objects as shown below.
d) During the animation, we want the conveyor belt to appear to rotate clockwise. For the chosen animation, this means we need to select the left-side object and press [Arrange] – [Vertical Flip], then select the right-side object and press [Arrange] – [Horizontal Flip]. Then, position the objects so that they appear to form a single conveyor belt as shown.
e) Go to [Draw] – [Rectangle] and insert a rectangle object in the graphic page. Place the object directly above the left conveyor object, as shown.
f) Select the ‘H-Move’ function in the rectangle’s [Object Configuration] window. Enter the name ‘BOX’ in the tag field and assign the data range from 0 to 30.
g) Set the base position as ‘Left’ under the [Horizontal Move] tab. Set the distance to 380.
h) Create a new ‘Start Up’ script called “script” in the [Tools] – [Script] editor. Edit the contents of the script as shown below.
i) Go to [Draw] – [Switch/Lamp] and create a bit switch to control the ‘CONVEYOR’ tag.
j) Launch the project in Xpanel or the simulator. When the switch is pressed, the conveyor belt and box will begin moving. The rectangle object moves from the left of the belt to the right side. When the ‘BOX’ tag value becomes greater than 30, the analog value will be reset to 0 and the box will move back to the left side.