XCode, SpriteKit: How do you add buttons? - xcode

I've created a game using Sprite Kit. The game runs just like the iOS game Pop The Lock. I've already got a lot of code within my touches began. Because of this, whenever I try and add a Button to the scene and tell it to do something, all it does is start the game as I've told it to do that my touches began and it doesn't run what I tell it to. How do I add a image as a button that once I tap, it runs only that and not the other things in the touches began? I understand this is very broad but I'd like to see how people add buttons to the scene without affecting anything else. Cheers!

Related

Cant edit animation once created in Unity?

Im having a very weird/frustrating problem, cant find anyone who's found a solution but I know I'm not the only one. After creating animations in unity, I'm unable to edit/change them. Only create new ones.
I have created an animation and attached the animation to a game object. The game object also has an animator attached, but I don't use it for running the animation. I run it by code.
I have tried clicking the game object and opening the animation window, double clicking the animation, opening animation, everything but all I get is:
I cant go back to one animation. How can I do this?
My inspector looks like

Unity: GUI button with event trigger as virtual control pad on Android phone

Let's say I have two GUI buttons with EventTrigger as virtual key. The expectation is whenever a button is pressed, the camera will rotate until the button is released.
At the beginning, I used the pointer Down and pointer up function. It works, but it extremely sensitive, the camera rotation didn't stop at the moment when I release my finger. I've solved this problem by using drag function (whenever dragging is detected, the camera stop rotating something like that).
However, there is still a bug that I couldn't solve, that is if I swipe the button instead of touch&release, the button doesn't release. eventually the camera just keep rotating until I touch the button again. I've tried all the event trigger function such as pointer exist, end drag etc.
I just want the touch input works as perfectly as the keyboard input.
This problem doesn't shown when I debugging on unity remote, only when I build it on my phone. So is that hardware issue? (I'm using mi3)
Thanks for having time to read my broken English.
I'm so sorry that I've asked a stupid question, since I'm still kind of beginner. The problem is somehow it didn't update when I installed it in my phone. It actually works fine.

Xcode Buttons overflowing screen

I am trying to create a simple keypad in Xcode, using swift. I set up my keys how I want them to look, but when I run it, half of the buttons are off of the screen. Depending on the simulator, it can be pretty bad.
I was looking at this project:
https://developer.apple.com/library/ios/samplecode/UnitTests/Introduction/Intro.html
It is a simple calculator application with a bunch of buttons. When I run this app, the buttons do not flow off of the screen, no matter which simulator I use. I thought that this would have something to do with constraints, but there are no constraints on any of the buttons.
Can someone please tell me what it is about this app that keeps the buttons from flowing off the right edge of the screen? I've spent the last hour comparing it to what I have, and I cannot find a difference.

Creating splash screen Cocoa

I have been looking for a way to display a splash screen on a cocoa app im making(not iphone) and am very new im not asking if you think its a good idea or not because i know how it could be annoying for users. Its helping me learn.
I was wondering if there was a way to create a splash screen on a timer?
could anyone breifly walk me through it or point me in the right direction?
Easiest way I can think of is to add the splash screen's window to MainMenu.xib, and mark it as visible at launch - that way you don't need to worry about loading and showing it, all that will happen by default. In your app delegate's -applicationDidFinishLaunching:, start an NSTimer instance. When it fires, send your splash window a -close message.
(Edit) Okay, I know you didn't ask if it's a good idea or not, but here's my two cents anyway - if your app needs to load & initialize a bunch of plugins or perform some other lengthy operation before it's ready to be used, then a splash screen with an updating status would be less annoying than having to sit there just wondering what's going on...
(Edit.2) More about the plugin loading. You could write a method that loads one plugin, then uses NSTimer to call itself with zero delay if there are more plugins to load. Doing it via zero-delay timers, instead of a simple for() or while() loop, would allow the run loop to stay active, so you could update a progress bar and avoid the spinning technicolor pizza of death.

Any possibility to get a notification if another application receives a scroll event?

I'm developing an application in Cocoa which allows users to draw on any given window in OS X. The drawings move along with the corresponding window when dragged on screen. To complete this tie between drawings and the windows (and their contents) beneath, I'd like to catch scrolling events from the window in order to react on the positioning/visibility of the drawings.
An example:
The user opens Safari and browses the web. On a specific website s/he draws a circle around a link and takes hand written notes (this is all considered a drawing, input by a pen tablet). Afterwards s/he moves the window, the drawings are also being moved so that they remain on top of the link on the website. Then s/he begins to scroll the website and the location of the link changes (moves up until it's outside of the viewport).
Now I'd like to catch that event and also move the layer with the drawings to keep them on top of the link. When the link is no longer visible, I'd turn off the visibility of the drawing and turn it back on when scrolling brings the link back on to the viewport.
I know this is a quite tricky assignment and being able to intercept such events from another application might as well be considered an OS security flaw but maybe someone out there is good enough a coder to give me a hint... :)
The Cocoa Accessibility classes may be helpful but until now I haven't found the solution.
Thanks for your help.
Oh, and if that's not tricky to you, maybe you can tell me how to get notified when Safari switches Tabs ;)
kkthxbai
I'm not sure if you can monitor scroll events. However, it's a lot easier if you just monitor the position of the link with the Accessibility API.
Just hold a reference to that link and constantly poll it for its position, if the position changes, you know what to do.
You could also try using AXObserverAddNotification, but as far as I am aware, there is no notification you can monitor for position changes.
If you haven't discovered it already, the Accessibility Inspector can help you a lot with identifying things that you can get using the Accessibility API and pfiddlesoft's UI Browser lets you register for notifications.

Resources