Android :: Following Straight Line (via Path)?

Nov 4, 2010

I'm working on a game which will use projectiles. So I've made a Projectile class and a new instance is created when the user touches the screen:

@Override
public boolean onTouch(View v, MotionEvent e){
float touch_x = e.getX();
float touch_y = e.getY();
new Projectile(touch_x, touch_y);

And the Projectile class:
public class Projectile{
float target_x;
float target_y;
Path line;

public Projectile(float x, float y)
target_x = x;
target_y = y;
line = new Path();
line.moveTo(MyGame.mPlayerXPos, MyGame.mPlayerYPos);
line.lineTo(target_x, target_y);

So this makes a Path with 2 points, the player's position and and touch coords. My question is - How can you access points on this line? For example, if I wanted to get the x,y coords of the Projectile at the half point of the line, or the point the Projectile would be at after 100 ticks (moving at a speed of X pixels/tick)? I also need the Projectile to continue moving after it reaches the final point. Do I need to use line.addPath(line) to keep extending the Path?

I managed to get the Projectiles moving in a straight line, but they're going in strange directions. I had to fudge some code up:
private void moveProjectiles(){
ListIterator<Projectile> it = Registry.proj.listIterator();
while ( it.hasNext() ){
Projectile p = it.next();
p.TimeAlive++;

double dist = p.TimeAlive * p.Speed;
float dx = (float) (Math.cos(p.Angle) * dist);
float dy = (float) (Math.sin(p.Angle) * dist);
p.xPos += dx;
p.yPos += -dy;

The Angle must be the problem. I'm using this method, which works perfectly:
private double getDegreesFromTouchEvent(float x, float y){
double delta_x = x - mCanvasWidth/2;
double delta_y = mCanvasHeight/2 - y;
double radians = Math.atan2(delta_y, delta_x);
return Math.toDegrees(radians);
However, it returns 0-180 for touches above the center of the screen, and 0 to -180 for touches below.

Android :: Following Straight Line (via Path)?


ADVERTISEMENT

Android :: Using Touch Screen To Draw A Straight Line

Apr 13, 2009

Want to draw a line when I touch screen at two points. I can see OnTouch been invoked but after than everything breaks looks, the application crashes

I am using drawLine in Canvas.

CODE:......................

View 5 Replies View Related

Motorola Droid : Touchscreen Is Randomly Pressing In Exact Straight Line Near 2nd Column

Aug 3, 2010

My touchscreen is randomly pressing in an exact straight line near the 2nd column. Utilizing a program called steamy window, I could see exactly where the touchscreen was being touched. See attached photo.

Some Diagnostic Info:
- I live in SC where it has been quite hot.
- It first started this weekend after being in the car dock for 15mins. Afterward the phone was very warm.
- It seems to stop after the phone has cooled.
- It started happening again today in a 78 Degree air conditioned apt. after using the phone for 30mins.
- After letting it sit to type this, it has seemed to stop.
- Pressing the edges of the screen seems to reproduce the issue.
- Moisture stickers still have the red x's on em.
- My screen is as clean as can be

From reading other posts, I'm well aware it could be a moisture/humidity/heat thing. But it shouldn't be doing it in my AC'd apt. I'm also aware some say its greasy fingers/screen. But as I've mentioned my screen is very clean & it still does it.

Some History:
I've had my Droid since November. I've dropped it ONCE on the pavement some time in January/February. Afterward everything has worked fine. About 2/3 months ago I noticed my screen started randomly clicking things. (In my Apt.) Fearing it was going to call someone, I immediately did a battery pull & cleaned the screen. Everything was fine until this weekend.

I'm getting married mid august, and don't have a whole lot of time/money to fix this, but need the phone desperately during the next month. I was hoping someone would have some advice for me.

I do not have insurance. Is this covered under some warranty?
I am rooted (CM5.07/No Theme). Should I do a factory reset b4 I take it in?
Will they do anything other than tell me I'm screwed?

View 2 Replies View Related

Android :: Want To Draw Line Or Path On Google Map In HelloMapView

Feb 1, 2010

I'v been busy for a long long long time finding out how to draw a line between two (gps) points on the map in HelloMapView but with no luck.Could anyone please tell me how to do so.Suppose I use the HelloMapView which extends MapView. Do I need to use overlays? If so do I have to override the onDraw() method of the overlay and draw a line here? I actually tried these things but with no result.

View 5 Replies View Related

HTC Aria :: Keyboard With | Character (Straight Vertical Line Character)

Jun 22, 2010

I'm looking for a third party app/keyboard that features the | character; that straight up and down vertical line character. I need it to log into my email, but the stock keyboard doesn't seem to feature it. Anyone have any good ideas?

View 9 Replies View Related

Android :: Path To Array / Read Points On Path?

Jul 5, 2010

Is there a way to read the points created when drawing a path? It seems silly to me that a path cannot be readable.Or is it just better to manually write the current finger position to an array?

View 1 Replies View Related

Android :: How To Read A Local File Line By Line?

Jul 10, 2010

I have a text file in my res/raw directory. I want to read the file line by line, but FileReader and BufferedReader fail, because of Android's security restriction. How else can I do it?

View 1 Replies View Related

Motorola Droid :: Yahoo Mail App - Line After Line Of Code Instead Of Message Text

Sep 10, 2010

Recently I have been having issues with viewing my email messages in the Yahoo Mail App. When I open some messages all is see is line after line of code instead of the message text. It doesn't seem to matter what the source email is (gmail, hotmail, etc). Some emails are ok some are not. Anyone else have this problem? Any fixes?

View 1 Replies View Related

Android :: Text Alignment Line By Line In Android Text-view Using Gravity

Aug 31, 2010

Can we align our text line by line(I mean whatever the text we have selected that should be aligned instead of the whole text) in android text-view dynamically!

View 1 Replies View Related

Android :: Widget To Get Straight To 'network Operators'

Mar 16, 2010

Sometimes my phone loses signal, and then doesn't pick it up as quickly as I'd like.Normally,I go into settings, to 'wireless controls, mobile networks, network operators' to force it to pick up my network. I'm looking for either an app/widget/shortcut to take me straight from my homescreen to 'network operators' without having to click through the various settings menus, or advice on building the link myself.

View 4 Replies View Related

Android :: Send Contacts Straight To Voicemail

Feb 6, 2009

I know there is a way to send contacts straight to voicemail but is there an app that can block calls or can someone please make one.

View 10 Replies View Related

HTC Hero : Dumped TouchFlo And Gone To Straight Android

Aug 9, 2009

I got fed up with slow responses, graphical fripperies that get in the way and occasional incompatibilities and have now dumped the HTC user interfaces as I wasn't using their widgets anyway, that's all you really lose. Even HTC's home app has an annoying "overshoot" for effect when scrolling from one screen to the next, which just gets in the way. Looks nice at first but gets annoying after a week or so. Am now using stock Android and the phone's a lot quicker.

View 11 Replies View Related

Android : Way To Create A Shortcut To Go Straight To Call Log?

Apr 17, 2010

is there a way to create a shortcut to go straight to the call log? Its rediculous that we cant have a button to go straight to the last dialled contacts.. Since mobiles existed, when you hit the phone button you go into Cal Log...

View 4 Replies View Related

Android :: Any Application So That Outgoing Call Go Straight To Voicemail?

May 15, 2010

I thought I had seen some application where you can call someone and have it go straight to their voicemail. I've been looking around and haven't been able to find it. Does anyone know if such an app exists.

View 4 Replies View Related

Android :: Uploading Images Straight To Forums From Camera Possible?

Dec 9, 2008

Is there an application in the Market that will make it possible to upload direct from the camera to enable images to be inserted into forums. Either direct into the forum post, or via a hosting site like imageshack.

View 11 Replies View Related

Android :: Why Passing Objects To Intents Are Not Straight Forward?

Oct 29, 2010

Why is that the object has to be serialized or be Parcelable in order to be passed to an Intent ?

View 1 Replies View Related

Android :: TranslateAnimation Doesn't Animate Straight (X-only) But Also In Y-direction (diagonal) / Fix It?

Oct 26, 2010


I have a TranslateAnimation that shall animate a LinearLayout (isScrollContainer) to the left and to the right along the x-axis. The animation to the left works and the animation is straight - means that the view is animated horizontally only.

But the animation left to right doesn't work: instead of just moving the view from left to right along the x-axis, the view gets animated into the screen from diagonal lower-right corner. But for the Y parameters I pass fixed identical values.

Here is a flv movie that shows the animation and issue I described: http://tinyurl.com/24n4eac

Code as follows...

View 2 Replies View Related

Android :: Straight Forward Broadcast Receiver To Open / Read File

Apr 16, 2009

I would like my app to pop up in the list of options for opening certain file types in the various file manager, email, and web browser apps. I'm having trouble figuring out how to begin. I haven't found any examples of this sort of thing yet. Don't I need to know what kind of action the other app is trying to invoke on a selected file? How can I possibly know that? Or should I simply assume that all file manager, email, and browser apps will always use ACTION_VIEW or perhaps ACTION_EDIT when trying to send a file to another app? Must I simply assume this and hope I'm right? There are so many possible apps to try to get this to work with, how do I make it receive a "open-file" command from any arbitrary app? Is the code below correct so far? I have the following in the manifest:

<receiver android:enabled="true" android:exported="true" android:label="Some Label, where does this show up?" android:name=".MyBroadcastReceiver" >
<intent-filter> <action android:name="android.intent.action.ACTION_EDIT" />
</intent-filter> <intent-filter> <action android:name="android.intent.action.ACTION_VIEW" /> </intent-filter> </receiver>

I don't see how to specify a file-type or file extension filter in the receiver. How do I do this? Likewise I have the following in the receiver:

public class MyBroadcastReceiver extends BroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.intent.action.ACTION_EDIT")
|| intent.getAction().equals("android.intent.action.ACTION_VIEW")) {
Uri uri = intent.getData(); String uriStr = intent.getDataString();
} } }

View 10 Replies View Related

HTC Hero :: Emails Does Not Always Come Through Straight Way

Oct 28, 2009

i have 3 accounts set up on the phone, blueyonder(virgin media) hotmail and gmail. I use my blueyonder account for my job and it is important that emails reach me in a timely manner, i have come from a blackberry so no probs there. The porblem i am having is the dont always come through straight away, i have the phone set to check server every 5 mins, yesterday evening at 18.00 i received 9 mails all at once which had been sent from 14.00 onwards in the afternoon. I have also have had it when emails have come through a day late. Does anyone get the same problems, is this a phone problem or a virgin media problem, i suppose it could be a connection problem but i have wifi at my home and this was on from when i got home.

View 4 Replies View Related

HTC Desire :: Applications Started Going Straight To SD?

Oct 5, 2010

Over the last couple of days I have noticed that some applications have started going straight to SD? I have not followed the procedure favored on here for forcing applications to SD (yet). So why are they doing it? Its not a problem as I was going to move them anyway.

View 8 Replies View Related

HTC EVO 4G :: Straight Goes To Homescreen When Use Applications Or Browser

Jul 6, 2010

Whenever i am in an app or the browser, randomly at times my phone will just go straight to the homescreen. I do not hit the home button at all, it just goes there by itself. This happens on any screen, whether im browsing my pics, taking a pic, or browsing the net. Does anyone else have this issue? I noticed it started after the new update from htc.

View 1 Replies View Related

HTC EVO 4G :: Straight To Voicemail Option Not Working

Jun 7, 2010

I have put this as an option on one of my contacts and none of the calls are going straight to voicemail. For those who don't know, you can have a contact go straight to voicemail when they call. Its an option on the peoples app.

View 1 Replies View Related

HTC Incredible :: Phone Not Ringing / Going Straight To Voicemail

May 10, 2010

For some reason, my Pone does not ring when there is incoming calls. I ported my number on Thursday and on Friday, I had rings with incoming calls. But since yesterday, I have not heard any rings. Calls are going straight to VM. I thought it was a Google Voice thing. GV is known to have this problem in the past.) Then, I disabled my cell number from GV and calls are directed to the Verizon VM. I have not changed any settings.

View 1 Replies View Related

Media :: From Where To Download Movies Straight To DX For Free?

Oct 11, 2010

I was wondering if i can download any free movies straight from the droid x for free?

View 3 Replies View Related

HTC Desire :: How To Receive OTA Update Straight From Google?

Nov 18, 2010

I'm in Canada and with Telus. I'm asking all the Android and desire users on. How to receive stock Android updates from google via OTA, just like nexus one. I know that u can get stock Android through rooting and downloading the file. But I'm asking if it's ever possible to receive OTA update straight from Google without being altered by HTC and the service provider.

View 5 Replies View Related

HTC Hero :: Gmail Going Straight Into Unread Email

Oct 26, 2010

I just upgraded to 2.1 from 1.5.Before my gmail account would open up to my inbox label, no matter how many unread emails I had. Now it automatically opens an email as soon as I click on the icon.Is there a way to set this back like it was in 1.5 and have gmail go straight to the 'inbox' label?

View 1 Replies View Related

HTC Hero :: Phone Lagging And Not Performing Straight Away

Aug 10, 2010

im on rooted hero what would happen if i did a factory reset! having problems with phone lagging and not performing straight away, may be cause flashing roms all time may be clogged up, would it be still rooted if i did.

View 15 Replies View Related

General :: Galaxy S3 - Unlock And It Goes Straight To Messages

Dec 26, 2012

when I swipe the screen from idle, it goes straight to the messages, not the home page.

View 2 Replies View Related

General :: HTC One X / CM9 - Recovery Skips Straight To Boot

Jul 8, 2012

I have an htc one x. I recently flashed the cm9 rom and im not to keen on it so i know want to return to my old standard one.

When i go into recovery to try and restore my old rom it doesnt let me the phone just restarts and boots into the cm9 rom and not clockwork recovery. I think it would be a good idea to wipe the rom and clear my cache but i cant as i cant go onto cwm.

View 1 Replies View Related

Samsung Epic 4G :: How To Send Calls Straight To Voicemail?

Nov 26, 2010

I know I could send calls straight to voicemail on my Samsung Moment, is there any way to do it with the Epic? I cannot figure it out, and I've got some people I really don't want to talk to that cannot take a hint.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved