HW3_Student2_Example_work.docx: uploaded 29 June 2012 at 8:19 am

advertisement
Example of Student Work
HW3
This is an Etch-A- Sketch app. The interface looks like below:
When I tilt my cellphone to right, it will draw a line to the right. When I tilt my cellphone to left,
it will draw a line to the left. It draws lines according to the direction I tilt. If I shake my
cellphone, it will erase everything. It will never draw lines on the red boarders. It only draws on
the white canvas. When you tilt back, it will erase a little bit and the line.
When I click on the save button, it will save the picture on my phone.it will show the path on the
left top
If you want to see your image, you can just go to that location. When you scroll down, there is
an image buttom. Click on it. It will reterive the image. Use the red strip to scroll down.
I used the orientation sensor to detect if the cellphone has been moved by the user. If the
cellphone has been moved by the user, I use roll X magnitude to figure out how much it has
been moved on X axis (Left and right direction). I use Pitch X magnitude to figure out how much
it has been moved on Y axis. For the Y axis, I have to times -1 because if I don’t it will tilt in the
wrong direction.
First the canvas will draw a line from x location of the ball and the y location of the ball to the
changed X, Y location measured by orientation sensor. I update the location by using location of
the ball plus how much the ball was tilted in the x and y directions. If the sensor senses the line
to be black, it will change the dot color to be white, so it can erase what you have drawn.
I used to orientation sensor, screen arrangement, and button. I also learned code reuse. It
helped a lot to get ideas.
I learned how to use orientation sensor and I learned how to use accelerometer sensor.
Download