0

im new to this android things. And i have to develop an application that can help an autism to learn numbers. I have a few ideas and I've been trying to learn and implement the code. But it's failed. The question is how can i apply the motion code or sprite to draw a numbers or letter? For example like this, i wanna make the penguin move through the line and draw a number nine. enter image description here

There is example from mybringback.com which is the image move to draw a rectangle. How can i implement it to draw a number? Im sorry if i asking too much, i just trying to get some ideas.

user3057414
  • 41
  • 1
  • 9

2 Answers2

1

I think that you should first build an utility program, in order to create the "path vector".

What I mean by path vector is simply a vector of Points (where a point has x value, and y value). And your utility should let you draw whatever you want, with a simple pen. You should draw on surface and store points when mouse is down, and ignore points when mouse is up.

Then, in the main program, you will just have to read at the path of your number/letter.

I've tried to implement something like this for the Sugar OLPC platform, without serializing path into files : I was able to draw, and to view the animation. And I used the process I've just described you.

Hope it can help you.

P.S : I used the word mouse, but you guessed that I talk about finger ...

loloof64
  • 5,252
  • 12
  • 41
  • 78
  • Thanks sir. But how to build an utility? Do u have an example? I only know how to drag n drop, that the latest thing i learned. Hehe. – user3057414 Dec 26 '13 at 04:27
  • As I said you, I tried to implement it in Python for the Sugar OLPC platform, but without the serialisation of caracters files, that this time, you may need. And I suggest you to try develop it on plain Java Swing at least before doing it in Android. Maybe, if you want help, could we try to do it together in a Sourceforge (or github ... or whatever forge you want) for the plain Java version :) – loloof64 Dec 26 '13 at 10:52
0

There are various ways to achieve animation effects. One approach that is quite versatile involves creating a custom View or SurfaceView in which you Override the onDraw method. Various tutorials can be found on this; the official Android discussion of it is here: http://developer.android.com/guide/topics/graphics/2d-graphics.html#on-view

Your implementation will look something like this:

// Find elapsed time since previous draw
// Compute new position of drawable/bitmap along figure
// Draw bitmap in appropriate location
// Add line to buffer containing segments of curve drawn so far
// Render all segments in curve buffer
// Take some action to call for the rendering of the next frame (this may be done in another thread)

Obviously a simplification. For a very simplistic tutorial, see here: http://www.techrepublic.com/blog/software-engineer/bouncing-a-ball-on-androids-canvas/1733/

Note that different implementations of this technique will require different levels of involvement by you; for example, if you use a SurfaceView, you are in charge of calling the onDraw method, whereas subclassing the normal View lets you leave Android in charge of redrawing (at the expense of limiting your ability to draw on a different thread). In this respect, Google remains your friend =]

hunt
  • 372
  • 1
  • 10