4

Hello everyone and thanks for your time.

Introduction to the problem: Basically the main problem is that I'm designing an android tablet application and I don't know exactly which is the best way to implement the kind of design I've been thinking about. I've been reading that is possible to use another platforms apart of Android, like OpenGL or HTML, but I don't actually know how to do it and if its necessary.

What do I attempt to do? I didn't know how to explain exactly which is my idea using words so I decided to prepare a small image about it, here it is:

Design about what I attempt to implement

So, the idea is to drag&drop the buttons to the color square, and detect if they are colliding, if that happens, start an event. Then all the buttons are going to be ordered again by themselves.

Which is the question then? I'm new at android, and I have no idea which is the best way to start implementing this, if I should bet for OpenGL or program directly in android. And in both cases, which is the best way START CREATING something like this?

Last things: I want to make clear something, just in case: This IS NOT any school work that someone asked me to do, I'm doing it by my own. I'm NOT ASKING PEOPLE TO DO MY WORK I'm just asking your opinion and asking for help and guidance about how to start managing this. (so I want your professional opinion, not any single line of code) :D

Thank you very much to you all. :)

Martí.

TurboTi
  • 111
  • 2
  • 6

3 Answers3

2

This sounds like it'd be pretty easy to do in HTML / JavaScript using touch events, maybe using a support library for drag/drop events. I don't know if it matters to you, but the nice thing with that solution is that it'd port pretty easily from Android to other mobile devices.

Like Quintin said, if performance is a big concern you can optimize and go to OpenGL, but you can probably knock out a simple prototype in HTML in under a day...

Community
  • 1
  • 1
Coderer
  • 25,844
  • 28
  • 99
  • 154
  • So, if I would like to do it with OpenGL, where should I start, do you recomend me any good tutorial how to implement it? Because I must admit that I have no idea how to merge android and OpenGL in a project. Apart of that, the application is also using sound processing that I've already implemented in Android, so I don't know if this can cause any trouble if I go to OpenGL. And in case that I was trying to use HTML, the same as before? Which is the way to merge both languages? Thank you very much! – TurboTi Oct 17 '12 at 09:01
1

Open GL seems to be your best bet here. I haven't had much experience with Android OpenGL, but it is going to be the most efficient way to write the app - since you are dealing with collision detection and colours.

Android OpenGL will be the best option since it will be natively compiled by the ADK whereas HTML is going to be interpreted at runtime.

As far as using normal bland Android layouts, I would not recommend that, since this is not a "standard" UI using the standard components. You are creating an entirely unique interface that is very graphical, and so I would recommend sticking to that.

EDIT: You will find that by using standard layouts that ALL of your user interface components will have to be customized, and you will spend a lot of time in your onDraw() methods with the collision detection.

One problem with this is that you need to check whether the object collides with another object, making certain types of objects aware of each other, and may run the risk of circular references. Whereas if you use OpenGL, you can have one list of "Shape" types and then have a "checkCollision(Shape draggedObject)" method which iterates through the list of shapes and checks the collision using an optimized collision detection for the simplest object.

The second problem is doing collision detection in the onDraw() method will make your app lag and seem sticky to the user while performing a drag. The more components the more problems.

EDIT 2: Here are some resources for Android OpenGL: http://developer.android.com/guide/topics/graphics/opengl.html
http://www.learnopengles.com/android-lesson-one-getting-started/
2D example with OpenGL

Community
  • 1
  • 1
Quintin Balsdon
  • 5,484
  • 10
  • 54
  • 95
  • The same as I answered/asked to @Coderer, how do I integrate OpenGL (or another language) to an android project? Do you have any good tutorial for it? Thank you! – TurboTi Oct 17 '12 at 09:02
  • I have added some tutorials - just remember the downside of using OpenGL is now you have to manage most things yourself, like dragging etc. – Quintin Balsdon Oct 17 '12 at 09:13
  • Actually I wasn't afraid of collision detecting since I have to do it with a square, basically I only have to check if I'm dropping the circle inside the square or not, so I'll only check it in the moment of dropping the object :) The other thing that's giving me problem is that all this circles will have to be animated while they are being dragged, and if I create them dynamically with a bitmap (so they're not in the main.xml ) Now I don't know exactly how to animate them, most of the tutorials are using the view layouts and all this stuff! – TurboTi Oct 17 '12 at 09:29
  • The more I hear, the more I think that OpenGL is your answer. Animations while moving will be better served within that context than anywhere else. You could create an "AnimationShape" object and define the Animation whilst the object is in a certain state. – Quintin Balsdon Oct 17 '12 at 10:54
  • I was also checking for phonegap that seems to be very confortable to implement, what do you think about it? Anyway I will start testing with OpenGL and see how it works! :) – TurboTi Oct 18 '12 at 10:32
  • I am not very well versed in PhoneGap - but that is going to add layers to your project, not so much create simplicity. I am currently employed as a Mono for Android dev, and these frameworks are there to make it easy to transport code bases from one device OS to another, not to make UI design easy. You will find with those type of frameworks there is a lot of boiler plating that increases the size of the apps (along with adding a little for the framework itself). I am not saying don't use it, I'm just saying there is no such thing as a free lunch :) – Quintin Balsdon Oct 18 '12 at 14:06
1

in my opinion you don't need any framework. You can do it all with android. I would also advise you to use android. I'm not a good designer, but my suggestion would be for this:

2x Framelayout, for the color tools on the left side and one for the rightside For the color tools, for each 2 colors you can use LinearLayout. And if you want the exact backgraund design, you can design it with an image software and can set it in the background. for the colors, you can use an imageButton.

And i also advice you to read the tutorials how to design apps, here is a good tutorial: http://mobile.tutsplus.com/tutorials/android/android-layout/

fecub
  • 945
  • 10
  • 27