MapField Display problem - blackberry

I want to display MapField on Storm on Full Screen and for this i am using MapField.setPreferredSize(Display.getWidth,Display.getHeight) . But instead of seeing MapField of dimensions 320X480 ,i get MapField of dimensions of roughly 320X280 and remaining space(480-280 = 200) filled with black colour..I have crosschecked values of Display.getWidth() and Display.getHeight(320 , 480)

The problem is that on a Storm, Display.getWidth() and getHeight() don't return the same thing all the time-- they attempt to account for the presence (or not) of the soft keyboard. The point at which the system decides the keyboard is there or not is pretty irrational. (The Storm absolutely sucks, as I guess you've figured out.)
One way that seems to work is subclass sublayout(width, height) in your Screen. This will get called multiple times on the Storm, as the system flops its way around figuring out what's going on. So it means more calculation, but it works. The last values you see through there will be right.
Here's a rough template. Remember this is in your class that extends the Screen. (e.g. MainScreen)
protected void sublayout(int width, int height) {
super.sublayout(width, height);
// the screen is acutally width X height
// do your screen-specific stuff here
}

It sounds like your application is running in compatibility mode. You can check this using Application#isInTouchCompatibilityMode(). Touch Compatibility Mode fixes the drawable region of the Storms to 320x240, like you're experiencing.

Related

Why is object.y not positioning the image in Corona SDK?

displaycontent = display.newImageRect (rawdata[currentpath][3], screenW*1.1, ((screenW*1.1/1654)*rawdata[currentpath][6]))
displaycontent.anchorY = 0
displaycontent.y = screenH*0.78
My program loads an image from a database to be displayed on the mobile phone's screen, everything works correctly apart from being able to position it with the y coordinates.
The only thing that changes its position is the anchor point 0 puts the top of the image in the centre of the screen, and values from 0.1 - 1 all position it higher. Changing the y position via object.y has zero effect regardless of what I set it as.
(the size settings probably look a bit weird in the first line, but this is because the images are different sizes and need to show the correct proportions on different screen types).
Btw I am using a tabbar widget as the UI (in case that is relevant)
Any help would be appreciated.
Edit: I am aware that displaycontent is bad name for a variable because of its similarity to things like display.contentCenterY for example, this will be changed to prevent any confusion when I look over the code in future.
I went through my code and tried disabling sections to find the culprit and a content mask was preventing me from setting the position of the loaded images within it.
I will look over my masking code and fix it (should be straight forward now I know where the problem started).
If anyone else has a similar problem (where an image or object wont position itself on given coordinates) check your content mask as that may be the issue!

setting extent using setExtent in blackberry

I want to make use of the setExtent() method in blackberry.
Every time i use setExtent(), it allocates the space from the zero, zero coordinate to any custom field that i paint by extending the Field class.
I want when I draw any custom field from (100,100), then it should allocate space from (100,100) and not from (0,0).
my code looks like:
protected void layout(int width,int height)
{
setExtent(100,100);
}
Please help me out with any solutions.
What you appear to be trying to do actually doesn't sound like a very good idea. 100 pixels is a useful measure on one device, but 100 pixels on a 9300 is over 1/3 of the height of the screen, but on a 9800 is no where near that. I would strongly recommend that you do not use fixed pixel sizes for any Blackberry development.
That said, if you want to Field to start at position 100,100, you should use setPositionChild for that Field in the Field's Manager.
Before you start leaping off attempting this, I would recommend that you review the following:
http://supportforums.blackberry.com/t5/Java-Development/How-to-Extend-Manager/ta-p/446749
and
http://supportforums.blackberry.com/t5/Java-Development/Create-a-custom-layout-manager-for-a-screen/ta-p/442990
But perhaps the best options might be to explain what you are trying to achieve and we might be able to suggest an alternative.

Cocoa iOS Make CGPoints "Bigger" in UIView

Is it possible to make the default CGPoint size for an iOS app "bigger"?
For example, the iPhone's main view is 320 points wide - is it possible to change that to, say, 100 points, and base all calculations on that 100 (as in still be able to use CGRectMake, get sizes etc. normally).
So does anyone know how to subclass UIView in such a way as to make the above work, and, more importantly, would Apple allow it?
Thanks for your time!
Apply a CGAffineTransformMakeScale(320/100, 320/100) transform to your view so that it is scaled, and 100 points will be scaled to 100 * (320/100) = 320 points wide.
Or course, don't use magic numbers like above, but use some constant for the value 100 and something like [UIScreen mainScreen].applicationFrame.size.width (or view.window.screen.applicationFrame.size.width or anything similar) to get the width of the screen instead of the value 320 (because magic numbers are bad, and we never know if the size of the screen will change in any future like the height just changed with iPhone5)
Have a look at UIViews transform property. But this is probably a bad idea: If you rescale your coordinate system, almost all your views are going to be misaligned with the screen's pixels. This will lead to blurry display of text, lines and other graphics.
Why would you want to do this in the first place?

Scaling entire screen in XNA

Using XNA, I'm trying to make an adventure game engine that lets you make games that look like they fell out of the early 90s, like Day of the Tentacle and Sam & Max Hit the Road. Thus, I want the game to actually run at 320x240 (I know, it should probably be 320x200, but shh), but it should scale up depending on user settings.
It works kind of okay right now, but I'm running into some problems where I actually want it to look more pixellated that it currently does.
Here's what I'm doing right now:
In the game initialization:
public Game() {
graphics = new GraphicsDeviceManager(this);
graphics.PreferredBackBufferWidth = 640;
graphics.PreferredBackBufferHeight = 480;
graphics.PreferMultiSampling = false;
Scale = graphics.PreferredBackBufferWidth / 320;
}
Scale is a public static variable that I can check anytime to see how much I should scale my game relative to 320x240.
In my drawing function:
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.CreateScale(Game.Scale));
This way, everything is drawn at 320x240 and blown up to fit the current resolution (640x480 by default). And of course I do math to convert the actual coordinates of the mouse into 320x240 coordinates, and so forth.
Now, this is great and all, but now I'm getting to the point where I want to start scaling my sprites, to have them walk into the distance and so forth.
Look at the images below. The upper-left image is a piece of a screenshot from when the game is running at 640x480. The image to the right of it is how it "should" look, at 320x240. The bottom row of images is just the top row blown up to 300% (in Photoshop, not in-engine) so you can see what I'm talking about.
In the 640x480 image, you can see different "line thicknesses;" the thicker lines are how it should really look (one pixel = 2x2, because this is running at 640x480), but the thinner lines (1x1 pixel) also appear, when they shouldn't, due to scaling (see the images on the right).
Basically I'm trying to emulate a 320x240 display but blown up to any resolution using XNA, and matrix transformations aren't doing the trick. Is there any way I could go about doing this?
Render everything in the native resolution to a RenderTarget instead of the back buffer:
SpriteBatch targetBatch = new SpriteBatch(GraphicsDevice);
RenderTarget2D target = new RenderTarget2D(GraphicsDevice, 320, 240);
GraphicsDevice.SetRenderTarget(target);
//perform draw calls
Then render this target (your whole screen) to the back buffer:
//set rendering back to the back buffer
GraphicsDevice.SetRenderTarget(null);
//render target to back buffer
targetBatch.Begin();
targetBatch.Draw(target, new Rectangle(0, 0, GraphicsDevice.DisplayMode.Width, GraphicsDevice.DisplayMode.Height), Color.White);
targetBatch.End();

Mouse position issues in XNA 3.1

I am using XNA 3.1 for the a game development, I am having little issue with the mouse position, I am also providing the screen shots of the issue, for now in the code below I am trying to display text "Start" exactly at mouse Position but the location of the the text is around 200 - 250 pixels away from the cursor instead to be at the same point where the cursor is on game window.
void MenuMainMenuDraw()
{
// Main Menu After Draw
// Menu Option After Draw
MouseState ms = Mouse.GetState();
spriteBatch.DrawString(fontMenu, "Start"
, new Vector2(ms.X, ms.Y)
, Color.Red);
spriteBatch.DrawString(fontMenu, "Options"
, new Vector2((float)MENU_GLOBAL.MENU_POSITION_X, (float)MENU_GLOBAL.OPTION_POSITION_Y)
, Color.Red);
spriteBatch.DrawString(fontMenu, "Leader's Board"
, new Vector2((float)MENU_GLOBAL.MENU_POSITION_X, (float)MENU_GLOBAL.HIGHSCORE_POSITION_Y)
, Color.Red);
}
Regards
MGD
There are a few possible causes that I can think of. I can't see anything directly wrong with the code snippet that you posted, so if none of these things resolve it, post more of your code.
Does the same problem occur when you create a new SpriteFont using the default font face? It may be a problem with the spacing in the font you're currently using.
In your spriteBatch.Begin(...) code are you supplying a transformMatrix? If so, try just using spriteBatch.Begin() with no arguments. Are you doing anything unusual like applying an Effects to your SpriteBatch drawing?
Are you drawing to a render target that is then redrawn to the screen?
I've had mouse position issues that seemed strange if my game window was actually larger than the resolution of the computer screen that I was running the game on. Its a quick check but it just might help. (Also remember that XNA draws images from the center point, but I believe by default draws test from the text's upper left corner). Hope that helps

Resources