Skspritenode object initialization shows incorrect analysis and resolution in iphone 6 Plus

Source: Internet
Author: User

There is no problem with a Spritekit project running on other devices (either a real machine or an emulator), but on the IPhone6 plus there is an over-amplification of the Sprite object texture:

You can see that either the protagonist or the prop ball is too big.

Look at this. The sprite image is placed in the Atlas Texture set folder:

You can see that both PowerUp and Player have scaled versions: Player.png,[email protected] and [email protected]

In the properties of each picture to check the size of the picture is also correct, see not the horse problem ...

Find the code for the Skspritenode object initialization to see:

let"PowerUp")

It seems that there is no problem ... Suddenly think that the above images are placed in the texture set, then all should be added to Xcode to form an additional whole picture, is there a problem?

Put the player in a total of 3 pictures in Assets.xcassets:

PowerUp also do the same, and then compile and run the code again, this time all the elves are the correct size, no amplification situation! It seems that the @x suffix is only valid for direct image resources, because you put the picture in the texture set, so system processing will go wrong.

But what if I just want to use a texture set?

Change the original initialization code of Skspritenode to the following:

let"sprites")let texture = atlas.textureNamed("PowerUp")let orbNode = SKSpriteNode(texture: texture)

This time everything is fine:

Why is there a problem on the iphone6p? Because 6p introduces a new 3x mode, all previous 2x (including 6), it is estimated to stumble here;]

PS: If you change the code in 6p to the following:

let"[email protected]")

Attention is 2x Oh!

Skspritenode object initialization shows incorrect analysis and resolution in iphone 6 Plus

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.