Sprite Kit. SKSpriteNode not appearing on iPhone 4 but appears on 4S - sprite

I am creating a game using sprite kit. Everything works and looks great on all devices (including 4S) except on the iPhone 4.
All devices are running on the latest iOS 7.
Everything else seems to be working fine on the iPhone 4. Its just the background image sprite. That appears black instead.
My thoughts are that it is there but positioned off screen.
here is my code for adding in the background...
//bgImage
bgImage = [SKSpriteNode spriteNodeWithImageNamed:#"BG_1"];
bgImage.position = CGPointMake(self.size.width/2, self.size.height/2);
bgImage.zPosition = 0;
[self addChild:bgImage];
Question 1: As far as screens go, aren't the iPhone 4 and 4S the same? same size and both retina?
Question 2: Does anyone know of any reason, why this is happening?

The maximum texture size is 2048x2048 for iphone 4 and 4096x4096 for iphone 4s and above. If image size is too large it will show black image instead. I used to had this problem before and after I resized the image problem solved. Hope this will fix yours too.

Related

Phaser - Change width and height Camera

In normal i have canvas size 500x500 and it will create camera size (500,500)
But when i change
game.camera.width=5;
game.camera.height=5;
then visible area it the same? what will happen when change width and height camera, how to understand that thanks
Based upon the documentation and an older post from the creator of Phaser on the HTML5 Game Dev Forum where he said:
You're not doing anything wrong, you just can't change the camera dimensions - they match the game size at the moment.
and then in 2015 on the same thread:
So you can tell if something is within the camera bounds or not. Which is impossible if the camera doesn't have a size.
suggesting that things haven't changed since 2013, and the camera doesn't resize as you're expecting.
Testing as well suggests that things haven't changed either.

monogame screen resolution is incorrect

Monogame, or XNA really, is reporting the wrong screen resolution on my Surface Pro 3.
Using GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width and Height returns dimensions of 800 x 600, which is incorrect. So, I cannot set up my game size correctly.
I've been using this code without problem on an Acer V5 and can set the game resolution to a size I expect. This is because the GraphicsAdapter reports the correct screen size.
Whether using it as is, or docking the tablet with an external monitor, returns exactly the same resolution. What error is causing this?
This used to be a bug in Monogame, and was fixed.
If you are not building from the latest source code, it is possible that you still have the bug in your monogame dll.
See:
https://github.com/danzel/MonoGame/commit/0c36642129d89a12b30bcfc7d13256739d5483af

Retina Display and it's implementation confuses me

Ok so I have been working with a designer who made the mockup of app in Photoshop. I am not using iPhone statusbar and using custom navigation bar which the designer made of 100px. In that navigation he put an icon of 48 pixels.
Now I have to transform into code and I am using UIWebView for the purpose. The layout he designed, I am going to make it in HTML/CSS that will be loaded in UIWebView.
Now the issue is, the PSD he made for the screen has SIZE of 640 x 960. In Iphone4 it's resolution rather than Physical Size. Base on setting of 640 x 960 pixel Image/PSD, he made the top bar of 100pixels. Now If I follow him that things getting messed up.
What I did that I just made everything half of size to accomodate 320 x 480 sceen size in CSS. I set Navigation Bar to 50px(for 320 x 480) and I put #2x.png image (48 x 48) in it.
Now when I load app in my mobile it appears big as it should which gives me impression that 48 pixels did not appear as 24px Image with High Density.
I am quite confused, If I make 100px navigation bar then everything looks big as I am targetting big size while I have to target high resolution. How do I adjust elements(DIV) and Images in my scenario?
Take a look at these articles on using CSS3 media queries and the viewport tag in order to help manage styles between normal and high definition displays:
Targeting the iPhone 4 Retina Display with CSS3 media queries
iPhone 4 and iOS 4 Safari Detection and Behavior

What Android layout file does the HTC Evo 3d use?

I think the phone uses the layout-hdpi file but this doesn't seem right, mostly because its dimensions(540 x 960) are not what I'm used to seeing(480 x 800) for layout-hdpi phones. So what is the actually layout file used? Also, if it is layout-hdpi phone how can I stretch an icon that has a width of 480 to 540? Would I programmatically have to test the phone's dimensions and then expand the drawable-hdpi file to fit the various device dimensions? I looked at this link but they never specified what layout file was used.
Yes, HTC Evo 3d use drawable-hdpi images. You should have to put the Layout file also. Put the same file into layout-hdpi.
Now create the Emulator of the Resolution 540 X 960. And test the App in it. There should be minor difference between normal hdpi and HTC Evo Screen resolution. Manualy test it.
I am getting same trouble before some days. What i have done is: I am going to check the resolution of the devide screen size at run time. And if the Resolution is compare to that HTC Evo 3d then it will set the height and Width of the All Images at run time that fit to the HTC Screen Resolution.
That was the Best Solution i found till today to Make app for HTC Evo 3d.
For Checking the Resolution at run-time you can use this:
Display display = getWindowManager().getDefaultDisplay();
DisplayMetrics dm = new DisplayMetrics();
display.getMetrics(dm);
int width = display.getWidth();
int height = display.getHeight();
if((height==960) && (width == 540)){
// Do change the Image Height or Width or position
}
Enjoy. :)

More iPhone 4 resolution scaling fun

So I have two images set to fill the screen - one at 320x480 (iPhone 3) and the other at 640x960 (iPhone 4).
img.png (320x480)
img#2x.png (640x960)
In Interface Builder, I have img.png set to fill the view (it shouldn't be filling the iPhone 4 view, though, right?), and when I build and run, it is notably too small.
So, when I do the opposite, setting img#2x.png as the img, a giant blue question mark fills the view. The project still builds and the image fills the screen, but is very pixelated as if it has been rescaled. It shouldn't have been rescaled, though, as it is the higher resolution.
Now using...
img.png (640x960)
img#2x.png (320x480)
I've also tried switching which file takes the #2x suffix, but that has not helped either. With the smaller file taking the #2x suffix, and setting the image view to img.png, it shows up way larger than the view canvas, but way too small when on the phone. With the smaller file still having the #2x suffix, I tried switching the view to the new img#2x.png and once again got the oversized, pixelated question mark in IB and a low res full-screen image when deployed to the phone.
I also made sure that my view size was set to 640x960 in the size inspector. What else should I be doing?
Don't use #2x when specifying the image name. Just use the base name of the image (so in your case, just img). iOS will do the magic behind the scenes to use the 2x version if it's on a retina display and the regular version otherwise (including when you use a xib to lay out your interface).
The displayed dimensions of the image will always be the dimensions of the non-2x image. The retina display just displays 2 pixels for every 1 which is why the scale is 2.0 and you have to double the dimensions of the original image. So your view size in IB should be 320x480.
Edit
If IB is being finicky, especially in Xcode 4, just try deleting the xib and starting over. Sometimes it gets a bit corrupted and doesn't know what to do with itself. I've had to do this on one or two occasions, and it seems that it worked for the OP as well.

Resources