[Q] Creating a "dots" inspired game, need help with a touch concept. - Java for Android App Development

I am trying to develop a game that uses touch between multiple objects. I need to detect when multiple items are touched on one swipe of the finger. The game is similar to "Dots" if you have ever played it. So I need to detect when a dot is pressed and then from there when the finger is dragged to detect the next dot that is touched. I need to keep this going until the finger is lifted. Using dispatchtouchevent and viewgroups is on the right track I think, but that is the furthest I have gotten.

When you are tracking a single touch movement, all the events would be sent to a single view.
So instead of tracking touch events for each Dots, you should track touch events for the common parent ViewGroup.
Lets say you have a frame layout with all the dots places inside.
On ACTION_DOWN
create a Map<Rect, View> for all the dots, where Rect is the position of that view in the viewgroup,
Code:
Rect pos = new Rect(child.getLeft(), child.getTop(), child.getLeft() + child.getWidth(), child.getTop() + child.getHeight());
Essentially you need to create this map only once (and probably again after a relayout).
Then check which Dot was pressed using Rect.contains for each rect,
then on ACTION_MOVE,
Check if the same view was touched, and if not, again check for all the views to see if any other view was touched.

Related

converter program (finger friendly) need suggestions

Hi wanted to create my first program..
right now Im trying to make a unit converter that is finger friendly..
so far I've tested it and here is what I have so far..
any suggestions? regarding the buttons positions, the interface, etc?
thanks
Hi Providense,
Looks good so far.
Do you have a development schedule as to what it will convert?
Keep it up.
John
Provedence,
It seems that some people like to have a configuration facility.
So perhaps some suggestions:-
Favorites so that the list can be tailored to favorites for that person to save a more compact list of 'things to convert'
I would be happy to have any theme for now but cooks may prefer to add there own theme.
I have used this type of function with calculator type programs but they can become unweildy so one that is specific would be usefull.
Thanks
John
thanks Johny1fin
as of now these are the things i've done
Temperature:
degree Celsius
degree Fahreheit
degree Rankine
degree Reaumur
kelvin
Acceleration: (still doing it right now)
centigal
centimeter/square second
decigal
decimeter/square second
dekameter/square second
foot/square second
g-unit(G)
gal
galileo
gn
grav
hectometer/square second
inch/square second
kilometer/hour second
kilomter/square second
meter/square second
mile/hour minute
mile/hour second
mile/square second
milligal
millimeter/square second
still a long way to go. But the Acceleration should be done by today.
Then I'll add Area, Date/Time and etc
I like the idea of favorites. I'll see if i can implement that. Im still a beginner at programming. Using VB.net 2003 right now
oh by the way. Here's the main menu, where I will put all the buttons
providence said:
Hi wanted to create my first program..
right now Im trying to make a unit converter that is finger friendly..
so far I've tested it and here is what I have so far..
any suggestions? regarding the buttons positions, the interface, etc?
thanks
Click to expand...
Click to collapse
Providence,
It may be a limitation of the APIs but could the vertical scroll buttons be next to each other horizontally rather than vertically as this may produce larger buttons?
John
Look nice.. however, on the finger friendly issue, you may want to avoid the scroll list (on your first screenshot) and have another screen for the choice of (say) different temperature units. Something like, making a screen (of your second shot) for temperature units. If you get what i'm trying to say
thanks for the feedbacks i've changed how the scrolling works. Now im using a custom button for that.
Looking good providence
I am not sure if you like this idea, but I think it will be more useful if you can add:
- Currency converter
- Currency quick view (to view several currencies at once)
There is an example of a very nice and complete project with source code here:
http://www.codeproject.com/netcf/PocketCurrency.asp
Add option to have automatic currency update as well
[ x ] Update when connected to ActiveSync
[ x ] Automatic update every X hours
hi, well the main idea was to create a finger based Unit conversion program. To add Currency Converter would be a challenge for myself.
Since first of all, Currency changes daily, so there must be a way to update it. Secondly, im still learning how to program by self teaching myself on my free time.
By the way, Here's the latest screenshot of the program.
I fixed the buttons so its easier to use.
unfortunately, this will only work on PDAphones and not on smartphones. Since you'll need to use the touch screen as input method.
Here is an idea, as mentioned by one of the post above, instead of stacking your scroll button up and down, it may save you that more space if you were to stack them left and right.
From what it seems, the < and > , are buttons, which you use it to 'affect' your lists. If you were to (example) sandwish your list in between these two buttons, you would save like another 2 button height. Example.
Currently, you have the layout
Code:
. item1 <
. item2
. item3 >
. item4
if you can just do this (which is possible in VC, not sure about VB), instead
Code:
< .item1 >
.item2
So, instead of 4 item height, you are now only left with 2 items height.
ahh i see..
I tried doing it
< item 1 >
item 2
but i find it harder to navigate, since when you go back you have to drag your finger across the other side of the screen. And while doing that, you are blocking the item list with your finger.
I dont need to save space, i think i got everything in there..
by the way, here's the test i took
then again, if i put them on the sides, it makes easier for those who are left handed as well
The spaces you save, may able you to bloat up the keypad below.. from what it seems, now they are on the 'flat' side of it.
If you think the "left-list-right" is not very finger friendly, you can try the "list-left-right"? That is
.item1 < >
.item2
Hi thanks for the suggestions..
right now here is what i have, and will probably be the final change in the button positioning..
i got big fingers and I can use them without stylus.
Should have a pre-alpha version ready soon. As of now I've done temperatures and acceleration.
Will add more soon

[App Request] Gesture controlled favorite contact today plugin

I would like to see a today plugin that features quick contacts (Kind of like the HTC home plugin).
The features I would like to see are:
* Today plugin
* Either use photo or set text for each contact.
* Opens contact in default contacts app, doesn't just dial (ie so you can choose to send an SMS)
* Vertical or horizontal list scrolled by gesture. Vertical or horizontal option would be nice, but vertical scroll probably more important - a lot of cube apps (eg ultimatelaunch) are controlled by horizontal gesture, if we could have this contacts app controlled with vertical gesture it would not interfere.
Please note that I mean a gesture controlled list WITHIN the today screen window, not as a seperate full screen app - plenty of things already do this.
* No add contact interface would be required, adding contacts to be included in dialer into a regular outlook category would be perfectly acceptable. Showing photo if contact has one or name if not would also be perfectly acceptable rather than an interface to select that.
V2R Photo Dialer 2 is almost exactly what I want but is controlled by horizontal gesture only. I tried to contact V2R to request this change but I received no response.
[Edit: Thinking about it, it doesn't need to be a favorites dialler, it could just have tickboxes for each category - if you want to use it as a favorite contacts launcher, just set it to the "favorites" category only, or you could leave all categories on to show the whole contacts list]
I'm using Face Contact which has all you've asking for, except horizontal but if you use Ultimate Launch then you can exclude the plugin from the gestures of Ultimate Launch.
http://www.cnetx.com/products/contact/
Nice app - I prefer it to the V2R one. I have emailed the author asking for the option of vertical gesture to scroll the list. I don't care if the list spins horizontally as it is, as long as I can spin it with a vertical gesture so it don't interfere with ultimatelaunch.
evilc said:
I would like to see a today plugin that features quick contacts (Kind of like the HTC home plugin).
The features I would like to see are:
* Today plugin
* Either use photo or set text for each contact.
* Opens contact in default contacts app, doesn't just dial (ie so you can choose to send an SMS)
* Vertical or horizontal list scrolled by gesture. Vertical or horizontal option would be nice, but vertical scroll probably more important - a lot of cube apps (eg ultimatelaunch) are controlled by horizontal gesture, if we could have this contacts app controlled with vertical gesture it would not interfere.
Please note that I mean a gesture controlled list WITHIN the today screen window, not as a seperate full screen app - plenty of things already do this.
* No add contact interface would be required, adding contacts to be included in dialer into a regular outlook category would be perfectly acceptable. Showing photo if contact has one or name if not would also be perfectly acceptable rather than an interface to select that.
V2R Photo Dialer 2 is almost exactly what I want but is controlled by horizontal gesture only. I tried to contact V2R to request this change but I received no response.
[Edit: Thinking about it, it doesn't need to be a favorites dialler, it could just have tickboxes for each category - if you want to use it as a favorite contacts launcher, just set it to the "favorites" category only, or you could leave all categories on to show the whole contacts list]
Click to expand...
Click to collapse
You can do horizontal scrolling photodial with my app, throttlelauncher.... It's free, so if you want to, try it . You can install it from http://www.throttlelauncher.com. After making the full instalation (use the exe setup or install both cabs) here you have a little setup cab for a theme showing only a contact row (if you're interested, you can have much more showing app's and other stuff in multiple pages). So to sum up:
- Go to http://www.throttlelauncher.com/
- Ensure you install everything on the same media (SD or device)
- Install both cab or use the desktop instalation in full mode.
- Install the cab attached to this thread.
- Enable throttletoday today plugin (it might take a little bit to load)
- Add as much contacts as you wish to the row .
Feel free to post any comments, requests or constructive critics . You can customize an xml to make the photos biger, order them in multiple rows, remove the ad delete icons, etc. Hope it matches what you're looking for....
Thanks for that, but the ThrottleLaunch PhotoDialer only allows scrolling of contacts via a horizontal gesture. I need to control it with a *vertical* (up/down) gesture. Also, ThrottleToday will not show inside ultimatelaunch - it will show if I put it on the main Today screen, but trying to add it as a today plugin in ultimatelaunch does nothing.
I did get an encouraging response from the makers of Face Contact yesterday though:
Hello,
thanks for your feedback.
At first thought, the idea of using a vertical gesture and having the list scroll horizontally appears a little bit disturbing, but we think we understand the rationale behind your suggestion.
We will indeed play around with UltimateLaunch to see if you can find out an option that is both intuitive and that allows Face Contact to be usable within their interface.
As it is now a possible solution is to exclude our plugin from being affected by Ultimate Launch gestures, so that when our plugin is active (and only in this circumstance) the left-right gestures will actually scroll the contact list instead than spinning the cube. Then, as soon as you apply the left/right gestures outside of our plugin, the cube will take control.
When developing Face Contact we left the door open to the possibility of having a vertical layout of the contact list, though, of course, this doesn't fit well with the current Today screen organization, which assumes all plugins are placed horizontally. In other words, it wouldn't be that difficult for us to layout the whole list vertically instead than horizontally,
So, we will definitely keep your comment in mind, as it is possible that within a different context (such as Ultimate Launch), we could actually provide both a vertical layout and vertical gesture, which would indeed make quite a lot of sense.
At this stage, having just released Face Contact a couple of days ago, we are currently gathering feedback to see how to move on with further releases and updates.
So, your feedback is very welcome: thanks again.
Best regards,
The CNetX Support Team
Click to expand...
Click to collapse
I downloaded Face Contact last night, and so far I am liking it. The reason I went with Face over VR2 is the space issue. VR2 looked to take a lot of space up in the Today screen, and being on a 240x240, space is a big issue. Face seemed to take a minimum of memory and leave room on my screen. I have it in a Shell tab with the native Palm picture dialer. The only option I could think of adding is the ability to dial automatically when the picture is pressed. I know that can lead to a lot of mis-dialings, but maybe a setting like normal usage until the pic is pressed for a second or so, and then the chosen primary number is dialed. If that makes sense great, if not, please let me know and I will try to explain better!!
Here is a screen shot of where I have Face on my Today screen:
im using face contact. it does everything you are asking for. im also using ultimatelaunch, the two make beautiful music together. especially if you choose the "disable gesture" feature when you enable it in ul. ive played with this quite a bit, and it is very intuitive how smooth everything STILL works. especially for these to be a first version for both apps. experiment with it. the result is perfect
Lots of nice feedback here: thanks guys.
syrguy1969 said:
...
The only option I could think of adding is the ability to dial automatically when the picture is pressed. I know that can lead to a lot of mis-dialings, but maybe a setting like normal usage until the pic is pressed for a second or so, and then the chosen primary number is dialed. If that makes sense great, if not, please let me know and I will try to explain better!!
Click to expand...
Click to collapse
I'm not sure if this is referred to Face Contact, or to other software you are using. If you are actually talking about FC, then please note that you can easily reassign the TAP and TAP & HOLD actions to trigger different commands, including CALLING the selected contact. Just check the "Action Settings" screen and you'll find the options there.
Also note that when Face Contact is the active plugin you should be able to CALL the selected contact by simply pressing the START CALL key of your phone. This is usually easier and less error-prone than having to tap or tap and hold. And, if you call by using the START CALL key, you can use the tap and tap&hold actions for other things, such as displaying the shortcut menu, or accessing the Face Contact Manager.
PS: we have included quite an extensive help file, with lots of tips and tricks and information on things like this. Maybe you may want to give it a quick look.
I guess I missed the tap+hold part, that is exactly what I was getting at!!! I guess this app has just about it all for me then, I will keep testing like crazy, but so far I am very pleased with it!!!
i'm using throttle now, but the pics look like garbage. I'm seriously OCD about the dumbest stuff, so I'm still looking for an answer. I just want face contact to have a transparent background, and I'd buy it.
J Shed said:
...
I just want face contact to have a transparent background, and I'd buy it.
Click to expand...
Click to collapse
Hey Shed, please have a look at my post concerning the plugin background in the Face Contact thread here...
http://forum.xda-developers.com/showthread.php?t=378145&page=7
evilc said:
Thanks for that, but the ThrottleLaunch PhotoDialer only allows scrolling of contacts via a horizontal gesture. I need to control it with a *vertical* (up/down) gesture. Also, ThrottleToday will not show inside ultimatelaunch - it will show if I put it on the main Today screen, but trying to add it as a today plugin in ultimatelaunch does nothing.
I did get an encouraging response from the makers of Face Contact yesterday though:
Click to expand...
Click to collapse
Hi evilc!
Sorry for the delay on the answer. Vertical scroll on throttlelauncher is planned for a further release (probably 1.0), it's still alpha so many things are missing but I thought It will mach what you where looking for... Any way, I've install UL and find out why the plugin is not showing... seem's that UL doesn't work exactly like the today screen when hosting today plugins (probably to save some memory) so the today plugin exe is not launching. To sum up, to make throttletoday plugin show inside UL the only thing needed is running manually the ThrottleTodayPlugin.exe located on the throttlelauncher instalation path. At least that worked for me. Also as you've said the horizontal scrolling will interfer with the tab change gesture so disabling os setting a time out it is needed by now....
J Shed said:
i'm using throttle now, but the pics look like garbage. I'm seriously OCD about the dumbest stuff, so I'm still looking for an answer. I just want face contact to have a transparent background, and I'd buy it.
Click to expand...
Click to collapse
Hi shed!
If contact photos don't look good you can try playing with the config.xml file to change the contact photo width an height values (I recommend to keep the 3/4 ratio if you use standar photo dial photos). The config.xml file will be inside the PhotoDialer1Row (or 2Row if you use this one) on your setups folder on your throttlelauncher instalation path. All you need to do is search for the allcontactswithphoto tag and play with it's height and width attribute.
Gabibbo:
I saw your post and had already replied. I'm just waiting for the version to show up.
APBilbo:
I have thinkered with that setting, the problem is in just how throttle scales the images. I don't recall the terms, but the scaled images are distorted.
@evilc .... I too use face contacts in a UL panel. When you use the disable gesture feature, It only disables the gestures from being passed to UL in the active plugin area. You can still spin the cube via gesture in an inactive area of the panel. Or if combined with something else, an area that does not otherwise respond to a gesture. Try it out.... In my case I have found that though it is a great idea, the vertical gesturing is not necessary for a fully functional solution.
J Shed said:
...
APBilbo:
I have thinkered with that setting, the problem is in just how throttle scales the images. I don't recall the terms, but the scaled images are distorted.
Click to expand...
Click to collapse
Ok, thanks for the info... I'll take a look at that... It's NET.CF the one scaling the images.... probably there's a smother method to get it...
nextpimp said:
@evilc .... I too use face contacts in a UL panel. When you use the disable gesture feature, It only disables the gestures from being passed to UL in the active plugin area. You can still spin the cube via gesture in an inactive area of the panel. Or if combined with something else, an area that does not otherwise respond to a gesture. Try it out.... In my case I have found that though it is a great idea, the vertical gesturing is not necessary for a fully functional solution.
Click to expand...
Click to collapse
Yeah, I realised that a while ago, it is OK if you have something else in the UL tab without gestures disabled, so that you can gesture left in that area to spin the cube.
I think overall, the interface I would like would be gesture left/right between the faces, then up/down to scroll info on each face. I think for this interface, a vertical list would be more suitable than horizontal scrolling icons, it would just work better visually.
I really like the music browser in conduits pocket player - I would kill for one of those in a UL face along with a contacts list done in a similar manner on another face, thumbcal (with scroll month by vertical gesture) on another face... That would be nirvana for me.

[Q] Live Wallpaper Falling Images and Sizes

I am wondering how to take a bitmap image and have it drop vertically from the top of the screen to the bottom and then wrap and do it again. I can only find how to rotate it around a certain access in the help portions. I'm assuming we can use different speeds as well to do the dropping. Also, what sizes need to be set in the hdpi and so forth? It seems that 920x740 is way to big of a picture for that folder and would be a memory hog.
I've not done any wallpapers apps, but typically, to do what you intend, you'd create a thread (class derived from java.lang.Runnable) with a simple loop and a wait timer (call Thread.sleep(). As the loop iterates, send a message to a class derived from android.os.Handler. In the handler, update your coordinates and refresh your view with view.invalidate().
What has it drop? I'm curious how you have your program realize it needs to drop down and then wrap around. All I understand is how to make it rotate around a set axis point.
bearcatext said:
What has it drop? I'm curious how you have your program realize it needs to drop down and then wrap around. All I understand is how to make it rotate around a set axis point.
Click to expand...
Click to collapse
You're thinking at too high level. There is no built in api for falling objects or animating bitmaps, you need to do it yourself.
The way I do it on my doom live wallpaper is to create a java object for each character or projectile I want to draw. The object contains variables for current x and y coordinates on screen and a method to update the position for a new frame.
That makes sense, that is what I was thinking on my drive home today that maybe all it was is setting the x or y coordinates and subtracting or adding depending on how you want it to look. Thanks for the response though I think this is the second time you've helped me out so I appreciate it.

[Q] Mulitple surfaceviews

Hey,
I know that using multiple surfaceviews is not a good idea. With that aside...
I am trying to make an onscreen joystick to add as an option to a game I am working on. I have a tablet so there is a big enough screen for multiple people to play on the one device, but I want to be able to control from joysticks rather than touching the whole of the screen (as you can imagine 4 people would get in each others way).
I am currently using a surfaceView to display the game on and for single player the normal touchscreen is fine, but I dont quite know how to add the joystick version without putting the joystick on the game map (something I want to avoid).
I have created another layout.xml file to handle my second option, and using a relativeLayout I can put the surfaceview between two other controls (like buttons etc). I dont just want to but 4 buttons for left etc, as I want to have vairable speed which a current_touch_position - centre_joystick_position would achieve.
Sorry for the long entry, but I felt like I needed to justify myself.
Any ideas?
Many thanks,
Steaky
So if anyone is in the same situation as me heres how I solved it.
Using RelativeLayout as a base I split the screen into 3 sections - relativeLayout, surfaceView and relativeLayout. I created a Joystick class that extends the class Button (might change to Bitmap in the future, but I'll go into that). Then put this line into the XML wherever I wanted a joystick
Code:
<view class="com.steaky.game_1.Joystick" android:id="@+id/button_JS2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minHeight="100dip" android:minWidth="100dip" android:layout_alignParentRight="true"></view>
I used the setOnTouchListener to take the user input and control the cursor.
One problem I encounter was that Buttons only draw when they are no longer being pressed, so the crosshair showing where the user was ressing (and dragging) only updated when the user lifted their finger.

[Q] controling a vertical view pager from out side

Hello all i have a vertical view pager on the lower part of the screen ,
it works perfectly , from inside the part of the view pager ,
is there a way to control it from outside the viewpager ?
like if i scroll up from somewhere on the screen other than the viewpager it would still react to it
** note : the vertical view pager extends a viewgroup... **
thanks to all the helpers !
smackering said:
Hello all i have a vertical view pager on the lower part of the screen ,
it works perfectly , from inside the part of the view pager ,
is there a way to control it from outside the viewpager ?
like if i scroll up from somewhere on the screen other than the viewpager it would still react to it
** note : the vertical view pager extends a viewgroup... **
thanks to all the helpers !
Click to expand...
Click to collapse
I think maybe you need some code to catch your touches on the screen and scroll the viewpager dynamically by code depending on your touches.
That's the general idea or concept behind it i think but really i don't have a code example.

Categories

Resources