Swift 2 SpriteKit issues - swift2

So I am having some issues with my spriteKit game since upgrading to iOS 9 and even after upgrading to Swift 2. I mentioned 1 here Atlas images wrong size on iPad iOS 9
However I am having 2 more issues I cannot fix.
1)
All my particle effects dont work anymore. This is the code I use and they are just not showing up anymore. If I just use SKEmitterNode than it works, but I prefer to add the SKEmitterNode to a SKEffectNode as it blends much better with backgrounds etc.
This is the code.
let particlesPath = NSBundle.mainBundle().pathForResource("Thrusters", ofType: "sks")!
let particles = NSKeyedUnarchiver.unarchiveObjectWithFile(particlesPath) as! SKEmitterNode
let particleEffects = SKEffectNode() //blends better with background when moving
particleEffects.zPosition = 20
particleEffects.position = CGPointMake(0, -50)
particleEffects.addChild(particles)
addChild(particleEffects)
I read this
http://forum.iphonedev.tv/t/10-8-skeffectnode-or-xcode-7-or-my-issue/669
and it claims it was fixed, but it wasn't.
2)
My Game Center banners when I log in or when an achievement pops are now using the portrait banner, even though my game is in landscape. Therefore banners only cover half the top screen. It looks so bad and since there is no actually code for banners I dont even know where to start.
Anyone else facing these issues, its frustrating.
Thanks for any help or support.

Some updates to this old question. Believe it or not in regards to the particles, apple recently replied to my 1 year old BugReport to see if it is fixed in iOS 10. LOL
I heard rendering particles via a SKEffectNode way is not necessarily ideal in regards to performance and I am not using it anymore. Therefore I am not sure if the bug is still occurring with the later Xcode and iOS 9 updates or in iOS 10 beta.
In regards to the adMob banner, I simply had to change
let adMobBannerAdView = GADBannerView()
to
var adMobBannerAdView: GADBannerView?
and delay initialisation until ViewDidLoad/DidMoveToView.

Related

Got 6 hours for rendering one frame in blender, What am I doing wrong?

I'm new to blender, after creating an animation, I want to render it. With the help of a large number of guides on the Internet, I think, I got the optimal animation rendering settings, as a result, but the beginning of the animation rendering I get 6 hours to render only 1 frame.
A computer:
RTX 3050 Ti 4gb
Ryzen 7 5800
16gb RAM
Settings:
I realize that the problem is in my settings, but I do not understand where.
Also, for some reason, when rendering 1 picture, the entire background I created change to orange due to technical error:
View in blender:
After render:
Thank you a lot for your time, I would really appreciate your help
(Im using Blender 3.4)
To reduce the render time make sure you head onto Edit > Preferences > System in that make sure you have CUDA enabled in Cycle render services. And for the change in background, that can be caused by some bug. So, upgrade your Blender to at least 3.8, because that's more stabler the its previous ones. Also make sure you have all the dependcy files(.dll) fixed and your DirectX version is 11.

Swift 5 Migration has Change Circular Images

I have a table view controller with many table view sections. In each table view section, there is a table view cell. In each table view cell, there is a content view. In each content view, there is some text and an imageView. The image view is a round profile picture with border. It has always worked. This is the code for each image view:
self.imageView1.layer.cornerRadius = self.imageView1.frame.size.width / 2;
self.imageView1.clipsToBounds = true;
self.imageView1.layer.borderWidth = 2.0
self.imageView1.layer.borderColor = UIColor.white.cgColor
I just migrated to Swift 5, and the circles are now square. No coding changes have been made whatsoever. In fact, when I migrated, the changes that it showed that it would make shouldn't have interfered at all with the roundness of the image.
I am at an utter loss as to how to correct it.
Well, nothing suggested here or at Apple developer forums worked. I racked my brain for days...nothing. Finally gave up and decided to just remove it from the next version of the app. While doing this, I decided to try one more thing and it worked. In this line of code:
self.imageView1.frame.size.width / 2;
I started making the number 2 a smaller number. When I got to 0.6 the image was perfectly round again. I have no idea why everything worked perfectly using 2 before the Swift 5 migration...nothing was chnaged. I am just glad I finally got it to work. Thanks to all for your suggestions.

- [CAMetalLayer nextDrawable] issue on OSX 10.11 Beta 2

Whenever I add the CAMetalLayer to the NSView, the [CAMetalLayer nextDrawable] method will pass nil after 3 successful id<CAMetalDrawable>.
I tried two different ways to configure the setup. One, I used MTKView and used its CAMetalLayer, it didn't work. Second, used NSView and created new CAMetalLayer. That didn't work also. I had weird issues.
I want to know anyone else is having this problem and if anyone know a solution to resolve this.
Additional notes:
I don't want to use MTKView draw system by overriding its methods (not yet). Also this is not a problem on iOS 8 and I didn't tried my code with the beta release of iOS 9 (not yet).
Update
I reroute my drawable calls to use the MTKViewDelegate delegate. And from the drawInView delegate method, I was able to retrieve consistent drawable frames. However, I still would like to use the nextDrawable method directly from CAMetalLayer. Hope this helps anyone else.
I had this same issue, and asked Metal devs at WWDC 15.
How MTKView works: MTKView has limited number of drawables (probably 3), so when you are encoding frames there are few drawables you can draw to.
What you are doing: Your scene is probably quite simple, so you CPU can encode frames really fast. So it seems like, when CPU is 4 frames ahead of GPU, you ask for next drawable and since all (3) drawables are in use, it fails.
Solution: You need to use semapthore to wait for drawable when there is no free one.
Here's code to use:
let inflightSemaphore = dispatch_semaphore_create(3)
func drawInView(view: MTKView) {
// use semaphore to encode 3 frames ahead
dispatch_semaphore_wait(inflightSemaphore, DISPATCH_TIME_FOREVER)
self.update()
let commandBuffer = commandQueue.commandBuffer()
let renderEncoder = commandBuffer.renderCommandEncoderWithDescriptor(view.currentRenderPassDescriptor!)
renderEncoder.drawPrimitives()
// use completion handler to signal the semaphore when this frame is completed allowing the encoding of the next frame to proceed
commandBuffer.addCompletedHandler{ [weak self] commandBuffer in
if let strongSelf = self {
dispatch_semaphore_signal(strongSelf.inflightSemaphore)
}
return
}
commandBuffer.presentDrawable(view.currentDrawable!)
commandBuffer.commit()
}
This is not documented anywhere! The only written mention of that is in iOS project template (File -> New -> Project -> Game -> Pick Metal) in GameViewController.
I already filled a radar on this (no response yet), and would appreciate if you do the same https://bugreport.apple.com
Also you may find useful my github repo https://github.com/haawa799/RamOnMetal
Use #autoreleasepool for render in drawable.
https://forums.developer.apple.com/thread/15102
I forgot to come back to this.
This was fixed with OSX Beta 4. nextDrawable method is working correctly and passing back usable CAMetalDrawable objects. I guess I should've waited until the release version came out before posting this. I just wanted to let everyone else know about this problem back when the beta version was first released.

How can I correct TouchPanel offset bug with Windows Phone XNA game on WP8 720p devices?

XNA apps (WP7 or WP7.5 apps) that run on a WP8 720p device will get automatically letterboxed so the 480x800 BackBuffer size stays the same (for compatibility I presume).
This would be fine, except there appears to be a bug in the XNA compatibility layer. The TouchPanel reports touch locations that are off by the size of the top letterbox blank area.
This has two problems:
The user's touches will appear to be off making gameplay and menu navigation difficult.
Because it is off in the negative direction, the user will be unable to touch things at the very bottom of the screen at all.
I tried working around the issue by just factoring in 53 / 2 pixel offset (53 is the total amount of extra space in scaled coordinate, divide by two because it is only off by one letterbox bar - the one on the top). This does correct the touch location, but because TouchPanel internally clamps negative values to 0, it means that there is still a dead zone at the top of the game (because -22 through -1 should be translated to 0 through 22, but if all negative input values are clamped to 0 then information is lost and everything in the negative range will translate to 22 always).
Has anyone run into this and found a way to work around it?
I'v even tried resetting the TouchPanel.DisplayHeight/Width to the actual 720p values of the device and somehow it gets reset to 480x800 by the next frame update.
I just got this working, the TouchPanel.DisplayHeight needs to be set to 853 (if you detect you are on one of these 720p devices) very early. I do it at OnNavigatedTo from the main Silverlight page (this is SL/XNA actually).
Next, you have to offset every touch location and gesture location by + 53.0f / 2.0f.
I'm not sure why this didn't work before, as this is the solution I mentioned above that didn't seem to work because TouchPanel kept resetting to 800 height.
But, I got it working in both a reduced repro (new SL/XNA app) and my main game app.
I was working on a game a couple days ago.
It was packaged for 7.1, but worked fine on the 720p emulator.
I don't know much about the compatibility layer, if it gets effected by the size of images then here goes :
I created separate images for WVGA, WXGA and 720p. Used them and found out about the letterboxing and decided to use 720p images for all.
Probably doesn't help but there you go anyway.
This is great solutio what I found from here: http://developer.nokia.com
It's not just fixing issue with touch but it also remove black blocks from side. Of course depending about your programn this can cause some more issues since resolution and screen ratio will change.
if (Environment.OSVersion.Version.Major == 8)
{
int? scaleFactor = null;
var content = System.Windows.Application.Current.Host.Content;
var scaleFactorProperty = content.GetType().GetProperty("ScaleFactor");
if (scaleFactorProperty != null)
{
scaleFactor = scaleFactorProperty.GetValue(content, null) as int?;
}
if (scaleFactor == null)
scaleFactor = 100;
if (scaleFactor == 150)
{
SharedGraphicsDeviceManager sdm = SharedGraphicsDeviceManager.Current;
sdm.PreferredBackBufferHeight = 800;
sdm.PreferredBackBufferWidth = 450;
TouchPanel.DisplayHeight = 800;
TouchPanel.DisplayWidth = 450;
}
}

jQuery, change source to animate the rotation of a line. faster alternatives?

I am making digital instruments for a car. These instruments will be constantly updated by information through ajax. These instruments will be served from a server onboard the vehicle through WLAN (fast) to my iPhone 3G. Is imperative to the success of the project that the updating of the tachometer is smooth and very responsive. Otherwise, it will look retarded.
The first problem I encountered was when I made this demo where tachometer moves quickly back and forth between zero and a thousand RPM: http://www.kingoslo.com/instruments/ When viewed on my iPhone 3G, the arrow simply doesn't move back and forth smoothly enough.
This javascript works by changing the source of the arrow img-element (which is semi transparant {4 color png} floating on top the static picture of the scale {16 color png}, by the way).
I've been made aware of new image editing features in HTML5, and wondered if any of those, or any other methods will be more responsive. Also, I am getting an iPhone 4 for xmas, so that may be a bit faster, but I've got the feeling that it still will fall short for the current build, especially when I add the constant ajax updating that is required to keep the instruments change values as the driver drives along.
Thank you for your time. Any help is greatly appreciated.
Kind regards,
Marius
I think using canvas will result in much faster animation - it was created to handle drawing, whilst manipulating DOM elements is comparably expensive.
Mobile Safari is compatible with canvas.
Alternatively, you could try incorporating all the angles as one large CSS sprite, and then just manipulating its background-position CSS property (element.style.backgroundPosition in the JavaScript DOM API).

Resources