|
#1
|
||||
|
||||
|
DaveMac,
Since you are trying to bring the highest quality apps to the Zune HD, could you tell me where (or just give it to me) I could find documentation and other related resources on developing for the Zune HD. There used to be some stuff on create.msdn.com, but it has all been removed for WP7 stuff. Could you help? Thanks, jbgrzy (p.s. I am trying to make an app worthy of being in the marketplace, and I know many Zune HD users would be happy to have it, but I keep getting stuck on the specifics of how to accept input from the touch panel. The documentation on the msdn library is not helpful at all.)
|
|
|
|||
|
|
|
#2
|
|||
|
|||
|
WP7 and Zune both use the same exact interfaces in the XNA framework (for the most part)
Anything you find for manipulating the touchscreen on WP7 will be exactly what you need for the Zune. |
|
#3
|
||||
|
||||
|
Quote:
XNA 3.1 (the version you need to use if you want to develop for the Zune HD) does not have predefined gestures. The only thing they have is TouchPanelState which has the values: pressed, moved, and released. Which is different than a predefined gesture. Anyways, what I wanted was any documentation that used to be on the XNA Creators Club website (The name was recently changed to AppHub for WP7). For some reason they removed the documentation when they changed the name. So, in short, XNA 4.0 is different from XNA 3.1 when it comes to handling screen touches. Thanks, jbgrzy |
|
#4
|
|||
|
|||
|
Yes, XNA's different versions and platforms vary slightly, but they are similar enough. I wrote a tutorial a while back for coding an XNA game for PC - after that to make it work on PC, I just had to change the mouse input to touch.
Yes, WP7 has gesture support, but that really isn't hard to do yourself. A naively simple example: Record a Vector2 of their finger as the touch registers, then when it releases take another one and compare them. If it's moved more on the Y axis than the left, then its a swipe across and vice-versa. You can then also take a DateTime of when they touch and then compare that to the current DateTime when they release to see how fast they moved. So basically, read the MSDN docs and create.msdn.com tutorials on XNA for either WP7 or PC and then just change what you need to. |
|
#5
|
||||
|
||||
|
Thanks roguemat,
That gives me some pointers to work off of. Though I am still frustrated at the lack of documentation on programming for the Zune HD. There used to be stuff on create.msdn.com, (the remnant pages are still there, though the actual documentation isn't) but they must have decided that they didn't want that information there anymore because of WP7. Thanks again, jbgrzy (p.s. when are you going to get your website completely up again?) |
|
#6
|
|||
|
|||
|
It's true that the Zune's touchscreen input could use more documentation. It's also unfortunately true that it's nowhere near as easy as WP7.
Here's a quick intro: The first thing you want to do is create a TouchCollection. This class will store all the data from the touchscreen. Personally I usually make this a class variable (i.e., I don't instantiate it every Update. I don't know if this makes much of an efficiency difference). Code:
TouchCollection touchCollection; In the UPDATE: Code:
touchCollection = TouchPanel.GetState() Code:
foreach(TouchLocation location in touchCollection)
{
switch(location.State)
{
case TouchLocationState.Pressed:
{
//What you want to do when a finger first touches the screen
break; //break is necessary in "switch" statements
}
case TouchLocationState.Moved:
{
//Contrary to what you might think, a TouchLocation does not only
//switch state to Moved when it is moving. Moved is EVERY frame
//after the initial press, even if the finger is completely still.
break;
}
case TouchLocationState.Released:
{
//This is the frame directly AFTER a finger is removed from the
//screen. When you're dealing with buttons, etc, you generally
//want to make the button activate here, just like you can hold
//your mouse on a button for as long as you want and it only
//activates when you release.
break;
}
}
}
Checking to see if a user touched in a certain area Code:
Rectangle myRect = new Rectangle(x , y , width , height); Code:
if(myRect.Contains(new Point((int)location.Position.X, (int)location.Position.Y)) //do something! Determining the velocity of a moving touch In the TouchLocationState.Moved case: Code:
TouchLocation previousLocation = location.TryGetPreviousLocation(out previousLocation); float velocity = Vector2.Distance(location, previousLocation); //OR float realVelocity = velocity / gameTime.ElapsedRealTime.Seconds; I'm actually a little shaky on my Vector math, but you could theoretically find all sorts of things from the previous location, such as a unit vector for direction, etc. I hope this was helpful. If there's anything specific you'd like to know how to do, just ask. Once you understand the nature of TouchCollection and TouchLocation, you can understand the possibilities of what to do with them. For instance, did you know each TouchLocation has a Pressure property?
__________________
- Grant F Last edited by FallenArms3; 03-30-2011 at 01:08 PM. |
|
#7
|
||||
|
||||
|
Thanks FallenArms3,
That will be tremendously helpful. Thanks for taking the time to write all that out. Interestingly, I have gotten more help from this forum, then the forum dedicated to the xna framework at forums.xna.com. Thanks again, jbgrzy |
|
#8
|
|||
|
|||
|
Quote:
I've found the Development Discussions section of ZuneBoards to be very helpful for Zune coding, though. I would highly recommend it as you move forward. Feel free to contact me, too.
__________________
- Grant F |
|
#9
|
||||
|
||||
|
Ok, so here is what I got.
Code:
TouchCollection touchCollection = TouchPanel.GetState();
TouchCollection touches = TouchPanel.GetState ();
foreach (TouchLocation location in touches)
{
switch (location.State)
{
caseTouchLocationState.Pressed:
{
loc1 = location.Position.Y;
}
break;
caseTouchLocationState.Moved:
{
TouchLocation prevLoc;
if (location.TryGetPreviousLocation(out prevLoc))
{
loc2 = prevLoc.Position.Y;
}
}
break;
caseTouchLocationState.Released:
{
}
break;
}
}
// check if touch moved up
if (loc2 < loc1)
{
distUp = loc1 - loc2;
isUP = true;
}
//check if touch moved down
if (loc1 < loc2)
{
distDown = loc2 - loc1;
isDown = true;
}
// if the touch moved up
if (isUP == true)
{
fontPos.Y = (fontPos.Y - distUp);
isUP = false;
}
// if the touch moved down
if (isDown == true)
{
fontPos.Y = (fontPos.Y + distDown);
isDown = false;
}
Does anyone know why? Thanks, jbgrzy |
|
#10
|
|||
|
|||
|
I don't have time to go through the code to see the problem, but what it looks like you are doing is just moving the text with the finger.
Instead of all that code you did you can instead just do this: Quote:
|
|
#11
|
||||
|
||||
|
Quote:
Thanks though, jbgrzy |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 01:59 PM.












Follow me on
Linear Mode
