xna wp7-trying to get a texture2d from photoChooser - windows-phone-7

in my optionMenuScreen the user picked a poto and then pressed back to the mainMenu and then playGame.
when i'm trying to get the photo in the gamePlayScreen after pressing the back button, its null again.
OptionsMenuScreen photo = new OptionsMenuScreen();
PhotoTexture = new Texture2D(ScreenManager.GraphicsDevice, 50, 50);
PhotoTexture= photo.photoRecieved;
PhotoTexture = Texture2D.FromStream(ScreenManager.GraphicsDevice, photo.PhotoResult.ChosenPhoto);
PhotoPosition = new Vector2(650f, 150f);
1. do i have to go straight to the next screen without back button or do you have another solution? what can i do to make it work?
2. how to enable the user to crop the picture as he wishes to the size i define?
help!!!
thanks alot

Please include the code for the Photo Chooser; you haven't actually included the code that is your issue, which is why your having this problem :-)
Check that you haven't actually disposed the photo that was taken; in this scenario you can just test with a static variable to hold the texture between the two classes.

Related

Second client's canvas not registering input? Unity

Obligatory "i'm very new". I couldn't figure out how to hook up a canvas that the player interacts with (chooses which team they'll be playing on in the game) that I had would work out if it was in the scene that the player prefab would be spawned into. So I put the canvas into the prefab with the player and set it as inactive once they select which team.
It works flawlessly for the host client (changes their "playerTeam" int and spawns them where they should be spawned) but when the second client joins their canvas is there, but won't take any input. I know it's this because the debug.log i put in right after input is not being run. here are the code segments that are necessary.
i have the canvas disabled by default and activated after an (isLocalPlayer) run on a script on the parent object. I can't add a networkID to the canvas because the prefab parent object has the networkID and they both can't have one, which means I cannot use (isLocalPlayer) on the canvas script, which may be the issue. But I also can't have the canvas on the actual level screen because even if i find the game object of the canvas, i don't know how to make it find which player to assign the playerTeam int to.
The following is run on a script attached to the canvas (of which the empty player object is the parent of)
Button CT = chooseCT.GetComponent<Button>();
CT.onClick.AddListener(parent.GetComponent<Sync>().CmdpickedCT);
and this is the code that runs on a script on the parent object
[Command]
public void CmdpickedCT()
{
GetComponent<Movement>().playerTeam = 2;
teamSelector.SetActive(false);
}
I apologize if I'm missing something big here. Thanks for any help.
for more information i have more stuff in the movement script run once the playerTeam is set to something other than 0, this also works on the host. Any other information you can give about how to pass info from the objects in the game scene to the instantiated objects would be great too. Thanks again.
Additional information, it seems like if i have both the second client and first client on the canvas at the same time, I cannot choose my team with either. It says "Trying to send command for object without authority".

How do I change images with buttons in .vb?

I'm coding a turn-based battle game and I cannot figure out how to make a button show a certain image on a different form on visual basic. This is my code if it helps:
Form1.plyrs_sprite = Image.FromFile
Why don't you just create a new form with just the desired image and open it up when the button is pressed e.g. the new picture is in form3
me.hide()
form3.show()

Wide Tile Windows Phone 7.1 using MangoPollo

I have a Windows Phone 7.1 app and I want to include a wide iconic tile. I found a library called MangoPollo:
http://mangopollo.codeplex.com/
I found this code within:
var tile = ShellTile.ActiveTiles.FirstOrDefault();
if (tile != null)
{
var tileData = new FlipTileData();
tileData.Title = "Start Debugging";
tileData.BackContent = "switch to windows phone, we've got candy";
tileData.BackgroundImage = new Uri("Assets/tileBackground.png", UriKind.Relative);
tileData.BackBackgroundImage = new Uri("Assets/tileBackBackground.png", UriKind.Relative);
tileData.WideBackContent = "switch to windows phone, we've got candy";
tileData.WideBackgroundImage = new Uri("Assets/wideTileBackground.png", UriKind.Relative);
tileData.WideBackBackgroundImage = new Uri("Assets/wideTileBackBackground.png", UriKind.Relative);
tile.Update(tileData);
}
The problem is there isn't any documentation included on Codeplex for the project so I'm not sure where to insert this code (i.e. which function) to change the tile size from normal to wide.
Another way of creating Wide Tile in Windows Phone 7. Tested it and it works.
Check this out.
http://www.supersmithbros.com/index.php/latest-news/93-how-to-create-a-wp8-wide-tile-in-wp7-xna
You may call it where you want and there is no code to change tile at the user screen, because it's not allowed.
If you look in the source code, in the link to MangoPollo which you supplied, the sample code places the tile code in a button click event. So what I would do in your app, is make an option to set up this new tile (settings page, maybe?) and when the user turns this setting on, you would run the code in that event handler.
This way, the code doesn't unnecessarily execute multiple times (as it would if it were in the constructor of a page or in app.xaml.cs).
Hope this helps!
Edit:
Based on your comment then, maybe you can put it in the constructor of your first page. Maybe, then, to prevent the code from executing more than necessary, you could check the existing tile to see if it already has a WideBackgroundImage, and if it doesn't, then set it and call Update() otherwise just continue.

Change the colour of WinJS.UI.BackButton (Win 8.1 back button)

I'm getting started with Windows 8 App development using WinJS. I'm using the Light UI theme but I have set up a darker area on the left of the page (where the black back button is) and the issue is: you can't see the button.
I've trawled through the MSDN pages and the most I could find is how to style a button which doesn't actually explain how to change the colour of an actual asset.
http://msdn.microsoft.com/en-us/library/windows/apps/jj835822.aspx
I've also tried adding: win-ui-light and win-ui-dark classes to the button with no success.
I wondered if someone could point me in the right direction?
Many thanks for your time
Chris
First of all you have to delete the link tag that contain UI css by default and add it to document head , Dynamically.see below code :
var uistyle;
// call when your app load or resume.
function onappopen(){
uistyle = document.createElement('link');
uistyle.href = "//Microsoft.WinJS.2.0/css/ui-dark.css";
uistyle.rel = "stylesheet";
uistyle.id = "UIstyle";
document.head.appendChild(uistyle);}
// call when you want to change UI Style.
function UIstyle(UIbool){
if(UIbool=='light'){ uistyle.href = "//Microsoft.WinJS.2.0/css/ui-light.css";}
else {uistyle.href = "//Microsoft.WinJS.2.0/css/ui-dark.css";}}
Like: UIstyle('light'); for light UI in Windows 8 or "UIstyle()" for dark;
I used the DOM Explorer to find the buttons default values and overwrite them. It was the child element that needed to be overwritten: .win-back

How to fix overlapping objects on the stage in AS3

I have a flash game where I have a picture designed to be the textbox for a prompt and textbox inside with the relevant text but the textbox is being hidden by the image. Anyone know how to make is so that the textbox is guaranteed to be on top or whatever I need to do to keep this from happening?
The other answer using setChildIndex will definitely work, however, I think a different design approach is really what you should be doing to remove the headache altogether.
For example in a game I might have different layers such as :
backgroundLayer
gameLayer
interfaceLayer
Those 3 Sprite layers would get added to the stage in that order. I would then add display objects to the appropriate layers. So anything I added to the backgroundLayer or gameLayer would ALWAYS be 'behind' my user interface on the interfaceLayer.
That allows you to not have to worry about the layering constantly. The answer with setChildIndex will fix the problem for that moment, but should something else be added to the container it will overlap your textbox, which is something I don't assume you want.
here's an example :
var backgroundLayer:Sprite = new Sprite;
var gameLayer:Sprite = new Sprite;
var interfaceLayer:Sprite = new Sprite;
addChild(backgroundLayer);
addChild(gameLayer);
addChild(interfaceLayer);
now, whatever you add to interfaceLayer, will ALWAYS be on top of objects you add to gameLayer or backgroundLayer.
So in the case of your text box, just add it to your interfaceLayer and any other objects you want behind it, you add to the gameLayer or backgroundLayer.
The order of adding display objects to display object containers effect their z-order, in other words the front to back order. The last added display object becomes the frontmost. So the child index of the children of a display object container is important for drawing of overlapped children.
If you put picture and text on the same DisplayObjectContainer such as a MovieClip:
Lets say your DisplayObjectContainer is mc.
And your textbox is txt
Please try this:
mc.setChildIndex(txt, mc.numChildren-1);

Resources