NSSplitView Proposed split divider not going to right place? - ios

I have an NSSplitViewDelegate, and I'm constraining the SplitPosition. However, in an edge case, if I move the cursor dragging the divider off the edge of the screen, the divider itself starts at (0, 0). However, this happens even if the proposedPosition is 200, all I have to do is quickly drag the mouse off the screen. Is there any reason that the divider is being set to 0?
PseudoCode
constrainSplitPosition
ProposedPosition = 220 (after dragging mouse off screen quickly, so last marker is at 220)
splitView
(returns a drawnRect for the divider at origin (0,0), corresponds to mouse off screen).
Any ideas, thanks!

You need to add a constrainMinPosition function as outlined in the apple documentation.

Related

iOS Spritekit Scrolling Menu

I am implementing a horizontal scrolling menu for a SpriteKit game and have become stuck as to how to go about this. My strategy was originally to add all of my menu items to the scene and just pan the camera horizontally according to swipes.
The problem with this is that the menu is revolving/circular (last item links to the first, etc) so even if I repeated the menu items infinitely, after swiping constantly one direction, I imagine a coordinate limit would be reached and the app would crash.
My next solution is to add one menu item in my camera view, one to the left, and one to the right. Then upon swiping the correct item would move into my camera view via SKAction and the original item would move away. I would then removechild the farthest node from the camera, and add the next item to the scene in the direction toward which I swiped. This way my x range (in points) would only be -displayWidth to displayWidth. The problem with this is that I would need to animate all of the menu items at the same time, and as they are separate nodes I have not seen a way to synchronize their animation.
Also I need to check the position of elements on the menu items and change their shaders when they reach the border of the screen. SKActions seem to block the SKScene update method so I am ideally trying to avoid SKActions.
Is there any viable strategy that I am missing here?
Since this is only a menu, it is ok to be a little inefficient.
What you do is have your menu cloned 2 times (so you have a total of 3). You place one of the clones to the left, and one to the right.
You then add all 3 of these into a parent SKNode. You should now have one SKNode with the 3 menu items in a long string. Make sure your anchor point is (0.5,0.5)
You then run the animation to pan left or right on the parent SKNode, with the condition that whenever you pass the edge of your original main menu, you jump in the opposite direction the width of the menu.
So let's say our menu is 400 (-199,200) points wide, and our screen is 300 points wide (-149,150). Once the parent point -200 (menu point 200 or right side of menu) aligns with screen point -150, you move the parent point to 200 (so menu point is -200 or left side of menu).
Since you are moving the parent node, all the clones will follow suit, and you only need to run 1 action.
I recommend using UIKit to create such a menu instead of SpriteKit. UICollectionView should be good for such a task.

Getting Screen Size XCode

I'm using spritekit to make an iOS game, and I came across a problem I've never had before. I want my game to be available on multiple devices, so I'm dynamically sizing everything based on the screen size, which I'm obtaining by using UIScreen.mainScreen().bounds.size, as was recommended online.
It's returning a screen size of 667x375. However, when I place an object at half the height and half the width, expecting to see it in the middle of the screen, it's instead displayed in the lower left corner.
Curious, I had it print touch locations from mouse clicks and discovered that the top right corner returns 1024x764 when clicked.
I've never had this problem before, and this is my 3rd XCode project. Can anyone help me?
UIScreen.mainScreen().bounds.size returns the size of your screen.
Sprite Kit uses a coordinate system different from a UIView. The bottom left corner of the scene is (0, 0). The values increase as you move up and to the right, so the top-right corner will give you the maximal value.
A scene's contents are scaled to fit the view based on the scaleMode property.
I suggest you re-read the Building Your Scene documentation.

Leaping image just before Constraint animation

I'm using Constraints within my app and have have a reasonable level of success so far; everything visual object in the gif below is Constrained.
The issue is that when selected, tiles leap to another location before animating to the final, correct destination.
From a code perspective, on a tile click, higher priority positioning Constraints are applied to the tile, the tile is added as a subview to the blue area, then animation is performed.
Can anyone shed a little light on what's happening here?
Thanks
Based on the behavior I'm seeing in your gif, I would guess that when you move the tile views between superviews (the blue area vs. the larger white area), the view jumps to it's current frame position (within the coordinate system of the old superview), but now in the coordinate system of the new superview.
The solution, I think, would be to translate the final position in the new superview to a position in the current superview, perform the animation, and only when the animation completes would you move the view to it's new superview.
Does that make sense?

Container scrolling on draggable moved to left or top

is there a good way to make the container div expand to the left and top when a draggable is dragged outside of its borders?
When you drag to the right or down the container div is properly extended, and scrollbars appear as needed. Yet moving to left or top means that the draggable items has negative top / left position, so the container is not expanded.
Here's a fiddle that demonstrates the existing dragging behaviour: http://jsfiddle.net/NPC42/Un23w/1/, but this can also be seen on the official jQueryUI demos too (http://jqueryui.com/demos/draggable/#default).
I'd like to be able to expand to the top / left too :)
A brute-force approach would be to:
Reset all of the object's positions on the container div to that no negative top / left is required (including the object being dragged).
Change the scrolling position to make it look as if the objects are still on their spots.
But for many objects in the container this could cause a lot of flicker, or even slowdown, so I don't really want to go in that direction. Any suggestions are welcome!
The problem is that every html element has an absolute (0,0) origin coordinate in the top left corner. When you drag in that direction the coordinates for the dragable become negative. However the scrollbars can not become negative, their size can only grow in a positive direction.
I can imagine a custom scrollbars widget that can adjust in a negative direction when you drag below (0,0). Also try having a container inside of another container with the inner one move around so that all of the objects inside it don't have to be individually moved. I don't know of any in existence as it would be kinda weird to have a negative scroll offset.

mouse jittering in the middle of screen in XNA

When I make the mouse visible, it jitters in the middle of screen. Does anyone know what the problem might be? thanks.
update:
I can't move the mouse.. it just stays at the same point
Are you setting the mouse position anywhere in your code?
This sounds like the result of an implementation of some "free look" code that sets the mouse position to the centre of the window each frame (so it can read how far it travels and then move it back, to allow for continuous movement without hitting the edge).

Resources