O'Reilly logo

Alice 3 Cookbook by Vanesa S. Olsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using variables to hold separate instances

In this recipe, we will use an array to hold two instances. Then we will change the contents for this array to hold another two instances. Two birds will fly towards the fence at the same time and then two other birds will do the same. The same array will change the Model instances in its list.

Getting ready

We will use an existing project that makes the four birds fly towards the fence at the same time.

  1. Open the project saved in the Using variables to hold instances of generic classes recipe.
  2. Click on Edit Code, at the lower-right corner of the big scene preview. Alice will show a smaller preview of the scene and will display the Code Editor on a panel located at the right-hand side of the main window.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required