Tuesday, September 29, 2009

This blog is based on Ostrich technology used in flash, illustrated on a website from
http://ostrichflash.wordpress.com/. There you will find working files, code, as well as video explaing the inner working of the code and its simplicity.
David Rokeby first developed this technology and its uses at Gesture tech. It uses the blend mode of the difference layer, black where there is no motion and other areas where there is, it puts a rectangle around it and we add a cursor to follow it.
it uses the "samples" package, within it, it imports flash.display.Sprite, flash.events and com.danzen.interfaces.ostrich package.
The class is named Sample Cursor. In it an ostrich camera and ostrich cursor are declared
within Sample cursor class, a public function SampleCursor is declared, a cursor is parented to the camera following the motion.
In the fairy example a same structure applies, the opacity of the camera is lowered using
the alpha channel.
myCamera.alpha = 0.2;

setChildIndex(myFairy, numChildren-1);
is sets the fairy icon on top of the camera
addEventListender(Event.ENTER_FRAME, animate);
calls on the animate function lo listen on the frame changes allowing for animated movement
In the fairy example the fairy cursor simply follows and x and y coordinates of the camera, in the animate tab.

Within the pong game or cursors files, there is one camera and two cursors, same as the previous example. This time there are two cursors, one listens on the movement of the left side of the screen and the other on the right side.
myCursorLeft = new OstrichCursor(myCamera, 0 , 0 , 100, 480,2);
the first four numbers indicate the coordinates of the area being looked at, the last digit (2) is the sensitivity, default of 4, the lower the more responsive and rigid the movements.
Working with these files, I found the pong code (cursors.as) the simples and shortest to follow, it enables beginner users, such as myself to follow the code, and what it's doing. Multiple paddles are declared and within the parameters of the camera capture they follow separate parts of the screen. With some interpretation of the code with the help of my class colleges I was able to add in a bouncing ball that bounces of the walls and both the paddles, in a old school style arcade.