How do windows phone app orientation work? - windows-phone-7

I am trying to make my first app using XNA, and I am having some issues with orientation and coordinates.
By default, my phone emulator is in portrait mode, but (0,0) is in the top right corner, and X and Y seem to be switched. from how I would expect them to be (x goes up, y goes across)
In my code, I try changing the orientation something similar to
SupportedOrientations = SupportedPageOrientation.Portrait;
SupportedOrientations.FullScreen = true;
And when I do this, it fixes the coordinate problems I am having, but then the screen becomes just a little square.
any ideas how to fix this? is this just how it is supposed to be?
Also, does orientation change automatically, or do I need to explicitly add
private void PhoneApplicationPage_OrientationChanging
(object sender,OrientationChangedEventArgs e)
Thanks

In addition to mandating the valid orientations, you should set your PreferredBackBufferWidth and PreferredBackBufferHeight appropriately (480 and 800, respectively, for current WP7). These are both found in the graphics member of the main Game class. You don't need to manually set the orientation.

Related

How to fix Blue Screen appearing after GameObject is removed in Unity 2d Project

I have been successfully building and running a Unity 2D game, but started receiving a Blue Screen during one of my operations. Specifically, when I close a popup and remove all of its child Game Objects, the entire Game Screen turns dark blue (the default background color of the main camera). The music for the game still plays and clicks are still registered if you click in the right area (I can still press the back button, just can't see it).
If I remove 1 gameobject, this problem doesn't come up. But once I have to remove 2 game objects, the entire screen turns blue.
This is my function for removing my game object in case it helps, which works perfectly when it comes to actually removing the gameObjects correctly (game objects to be removed are created from prefabs). I think the problem may be with the camera for some reason, but I have no clue as to why it happens on this function.
public void Remove(int index)
{
float toggleWidth = toggle.GetComponent<RectTransform>().sizeDelta.x;
DestroyImmediate(scrollSnap.pagination.transform.GetChild(scrollSnap.NumberOfPanels - 1).gameObject);
scrollSnap.Remove(index);
scrollSnap.pagination.transform.position += new Vector3(toggleWidth / 2f, 0, 0);
}
I don't receive any errors or warnings in the console. Just a blue screen once more than one GameObject is removed
EDIT:
Turns out my main Canvas's planeDistance was being changed from 100 to 3200. I still have no clue as to why this change occurred...but for anyone else having a similar issue with a dark blue screen appearing in the middle or start of their game, then please check the values your canvas and camera in the Inspector. Simply controlling the planeDistance did the trick for me!
Made a new scene next to the sample scene when i started my sprite learning game. Forgot all about that.
When I had to publish it, In the Build Settings, I had the wrong scene selected. So It published an empty scene instead of my game.
I solved it by putting game in 3d mode and realized that the camera is positioned very far from the sprites, just change the z-axis and again go to 2d mode.
Just Move your camera in Z-axis position, it could be too far from object or it is behind the object, you can also check it by 3D mode the check the object position and change it in positive and negative values.

Jagged edge Image on rotating with Evas map

I am making a watch application for Samsung Gear S2 with EFL Native application.
Problem was happened when I rotate hands of the watch.
Look at following image.
This is normal image I paste it to evas_object and it's not rotated yet.
After I rotate it, the edge of hands has changed to jagged shape like it.
Resolution of gear s2 is 360px X 360px so I make every image is fit to this size.
And I rotate image with following code.
Evas_Map *m = NULL;
m = evas_map_new(4);
//evas_map_smooth_set(m, true);
evas_map_util_points_populate_from_object(m, obj);
evas_map_util_rotate(m, degree, cx, cy);
evas_object_map_set(obj, m);
evas_object_map_enable_set(obj, EINA_TRUE);
evas_map_free(m);
I was try fix it with evas_map_smooth_set() function.
EFL document is written to this setting makes image to "SMOOTH"
and default setting is "true". but I worried tizen change it to "false".
But jagged shape is still showing Despite after I set true or false.
The Watchface that created by "Gear Watch Designer" has not jagged image on rotating there hands.
How I can rotate Image without jagged edge?
OK finally I found why jagged edge is appear on rotating.
In the emulator or my gear s2, default EFL rendering engine is not opengl backend.
So I can fix it with following codes.
elm_config_accel_preference_set("opengl");
Write this code before create window (elm_win_add) it will make anti-aliased image on rotating image.
Sorry for the very late answer, but I believe you can fix this issue in two ways:
Call evas_object_anti_alias_set() on the evas object that is mapped.
As you've mentionned in another answer, use GL acceleration but you may even want to enable MSAA on the backbuffer: elm_config_accel_preference_set("opengl:msaa");

Vertical NSLevelIndicator OSX

I wonder if there is a way of creating/modifying a NSLevelIndicator object so it can be positioned vertically, i.e. display discrete levels from bottom up, not from left to right, so it can be also used as element of interface-building library in Xcode?
There are lots of examples of such level displays in Apple and non-Apple OSX applications, and quite a few reasons why such an object should exist, yet how to create such an object for some reason (from what I can see in developer forums) seems either not worth asking or a "best kept secret".
Is there a template code which can be modified to into an object of such properties?
I haven't even faintest idea if such an object should really be written from scratch? Mission impossible?
Thanks in advance!
Try using
[NSView setFrameRotation:90];
it's sketchy but easier than a custom view
Edit: Alternatively try
[levelView setFrameCenterRotation:90];
SetFrameRotation:90 rotated it around the bottom left axis for me so it ended up being clipped. This one rotates it around the centre so you should be able to see it. I just made a quick swift playground showcasing it: http://cl.ly/WsL8/Vertical%20LevelIndicatorView.playground.zip
Edit again: If you're still stuck, I made a sample project with a vertical level indicator in objective-c: http://cl.ly/WrdH/levelindicator.zip
Swift 5.5.1 on macOS 11.6
myLevelIndicator.frameRotation = 90
If you need to reposition the indicator to fit within the view, realize the center of rotation is the origin of the level indicator.
So, to set the rotated level indicator 20px in from the left of the view, compute that for the new frame origin of the level indicator, not forgetting to adjust for the indicators height when it is horizontal because the original height will affect the final position when rotated.
myLevelIndicator.frame.origin = CGPoint(x: self.view.frame.minX+20+myLevelIndicator.frame.height, y: myLevelIndicator.frame.minY)
Of course, this can be avoided by placing the control in the correct position to allow for rotation within IB if that works for you. Some may not be using IB and creating these controls programmatically.

cocos2d-x 3.x on Windows: How do I change the size of my game window?

When developing using cocos2d-x 3.x for a device, it automatically sets the GL view to fit the device. In VS2012 on windows, it creates a seemingly-arbitrarily sized window. How do I set the size of that window?
My solution was as follows.
In AppDelegate.cpp:
bool AppDelegate::applicationDidFinishLaunching() {
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLView::create("My Game");
glview->setFrameSize(800, 600); // or whatever
director->setOpenGLView(glview);
}
...
}
In my particular use case, I'm setting the window sizes to various resolutions and aspect ratios to test my layouts. I'm sharing Q&A format because I couldn't find a straight answer to this anywhere.
+1 to Tom. Also, I would just like to share my answer and experience to everyone.
Remember, do not set the screen size "AFTER" the director set the GL view. This causes some problem with bounds detection on some nodes most notably cocos2d::ui::Button and other ways on how create buttons. I am using cocos2d-x v3.6
Check my answer here:
cocos2d::Menu click detection is a bit off to bottom left whenever using a custom window size
Doing this way will cause some problem:
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLViewImpl::create("My Game");
director->setOpenGLView(glview);
}
director->getOpenGLView()->setFrameSize(width , height);
Clicking the button, doesn't kick in the callback. Which is frustrating. Probably out of your frustration as well you click all through out the screen and notice there are some part of the screen (most likely bottom left part) which triggers the callback as if the bounding box of the node lies there. It doesn't even match the position and the size of the node in question. I can reproduce the problem whenever I change the screen size like the one I describe above. So never ever do it like that.
Tom's answer is the correct way of changing screen size.
I hope this will deter anyone doing it this way. I swear to God, this post could have save me heck of time solving this.
Cheers!

xcode drawrect - UIView bounds not reflecting rotation in simulator

I'm using xcode 4.5.2 to learn to develop in iOS6. I have this code in my drawRect...
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGPoint midPoint;
midPoint.x = self.bounds.origin.x + self.bounds.size.width/2;
midPoint.y = self.bounds.origin.y + self.bounds.size.height/2;
... etc
For some reason when I run this in iphone simulator, the result is always
midpoint.x = 160
midpoint.y = 252
regardless of whether the simulator (iPhone retina screen) is in portrait mode or rotated to landscape. The result is thus the graphic that I draw in portrait mode is centred on the screen correctly, but offset to the left in landscape.
Can someone suggest where do I begin to look as to why this is the case?
This drawRect code came directly from an earlier app I wrote which functioned correctly in terms of determining this midpoint of the screen (a UIView spanning the whole screen). This problem arises when I imported this code (the whole class) into my currently program which is segue-ing into instances of these UIViews.
Thanks.
figured it out, I think...
it appears that for unknown reasons (to me anyway), when the phone gets rotated, the view inside the phone did not get resized to fill the new vertical & horizontal dimensions. Thus the midpoint coordinates are always the same - because the view basically did not resize. In the size inspector, the view's got struts on the left & right only and no springs.
By adding both vertical & horizontal springs, the view seems to resize with rotation and the midpoint coordinate seem to change accordingly.
While I've gotten by my hurdle, I'm still unclear why I needed to add springs to the view, since the demo that I was following did not seem to require this step. Any suggestions would be appreciated. Thanks.

Resources