Date   

Re: Getting Started with Animations

Dave
 

Hi Again,

I’ve taken a look at Geek Game Board and I’m finding it a but hard to know where to start. I’ve developed my game to the point where the game engine sends messages to the Game View Controller which cause a Subview to the Game Cell. I now just want to animate that process, so basically in my view controller I want the View to fly across the screen from the left player area to a position in the board view. In order to do this, do I create a new CALayer or do I use the CALayer of the View I’m moving. I’m just having problems seeing where I add the code, simplified, the it looks like this:

GameViewController
RootView
LeftView
ScrollView
PieceView This View is taken from the Scroll View and 
RightView
BoardView
CellView1 to CellView81  Added as a Subview of one of these Views.


If anyone knows of a really simple Sample App that shows how to do this I’d be really grateful if you could point me to it. 

All the Best
Dave

On 13 Jul 2017, at 18:15, Jens Alfke <jens@...> wrote:


On Jul 13, 2017, at 6:13 AM, Dave <dave@...> wrote:

What is the best way to achieve this? Do I use CALayer? 

Yup, I would recommend using CALayers for the whole UI, pretty much. Back when Core Animation first came out I wrote a framework for building board/card games:
It hasn’t been updated since 2011 so it probably needs some fixes for API changes, but I still think the basic design is pretty well thought out. The goal was that you could implement a simple game UI in <200 lines of code, and there are examples included for checkers, tic-tac-toe, Klondike solitaire, and a few others.

—Jens


Re: Getting Started with Animations

 


On Jul 14, 2017, at 5:39 AM, Dave <dave@...> wrote:

I want the View to fly across the screen from the left player area to a position in the board view. In order to do this, do I create a new CALayer or do I use the CALayer of the View I’m moving. 

It’s been years since I did much with CoreAnimation, but IIRC a layer is clipped to its parent layer, so if you want this to happen you need to make the view temporarily be a direct subview of your RootView. I.e. remove it from its superview, add it to the RootView (doing some coordinate transformation so its at the same place on the screen), run the animation, and when the animation finishes do the same in reverse but ending up in the BoardView.

You may want to consider not using a view hierarchy, at least for the views that need to move around a lot.

—Jens


Apple Sample Code

Dave
 

Hi,

There used to a a web page that had a list of all the Apple Sample Apps, does anyone know if this still exists and if so, where?

I can’t seem to find it any more.

Thanks a lot
All the Best
Dave


WindowController

Gerriet M. Denkmann
 

This works:

- (void)showPreferences: (NSMenuItem *)sender;
{
(void)sender;

// if ( self.prefController == nil ) // this line should not be commented out
{
self.prefController = [ [ NSWindowController alloc ] initWithWindowNibName: @"PrefWindow" ];
};

[ self.prefController showWindow: self ];
}

But when I *not* comment out the if… line it works exactly once.

How can I convince my NSWindowController to keep its window?

Gerriet.


Game Center Multi-Player Question

Dave
 

Hi All,

I’m developing a game and want to use Game Centre, the game is for 2 to 9 Human or AI players, by AI I mean that that program itself makes a move on behalf of one or more AI Players.

So, in a 5 player game, the user could set it up as so:

Player 1 “Local User” [Human]
Player 2 HAL9000 [AI]
Player 3 Joe [Human]
Player 4 Marvin [AI]
Player 5 Sandra [Human]

As far as I can see, this approach won’t work with Game Centre, does anyone know if this is correct? And how to set it up if it is possible.

All the Best
Dave


Re: Apple Sample Code

nimeshneema@...
 

On 17 July 2017 at 17:10, Dave <dave@...> wrote:
Hi,

There used to a a web page that had a list of all the Apple Sample Apps, does anyone know if this still exists and if so, where?

I can’t seem to find it any more.

Thanks a lot
All the Best
Dave






Re: Apple Sample Code

Dave
 

Hi, Yes, thanks a lot! How did you navigate to it? I think it used to be built into XCode.

All the Best
Dave

On 17 Jul 2017, at 16:29, Nimesh Neema <nimeshneema@...> wrote:


Nimesh

On 17 July 2017 at 17:10, Dave <dave@...> wrote:
Hi,

There used to a a web page that had a list of all the Apple Sample Apps, does anyone know if this still exists and if so, where?

I can’t seem to find it any more.

Thanks a lot
All the Best
Dave







Re: Apple Sample Code

Gary L. Wade
 

On Jul 17, 2017, at 4:40 AM, Dave <dave@...> wrote:

Hi,

There used to a a web page that had a list of all the Apple Sample Apps, does anyone know if this still exists and if so, where?

I can’t seem to find it any more.

Thanks a lot
All the Best
Dave


Re: Apple Sample Code

Bill Cheeseman
 

https://developer.apple.com/library/content/navigation/index.html#topic=Sample+Code&section=Resource+Types

On Jul 17, 2017, at 7:40 AM, Dave <dave@...> wrote:

There used to a a web page that had a list of all the Apple Sample Apps, does anyone know if this still exists and if so, where? 

-- 

Bill Cheeseman - wjcheeseman@...


Re: WindowController

 


On Jul 17, 2017, at 7:12 AM, Gerriet M. Denkmann <g@...> wrote:

How can I convince my NSWindowController to keep its window?

Have you made sure the “release on close” checkbox isn’t set in IB?

(But do you really want the prefs controller to hang around when it’s closed? Seems like a waste of memory to me.)

—Jens


Re: WindowController

Jack Brindle
 

Is there a corresponding line of code that sets self.prefController to nil when the window is closed?
As I understand it, the property will only be set to nil if it is declared as weak, which is most likely
not what you want.

I get the feeling I’m missing something here, though. This is not something you would normally miss…

- Jack

On Jul 17, 2017, at 7:12 AM, Gerriet M. Denkmann <g@...> wrote:

This works:

- (void)showPreferences: (NSMenuItem *)sender;
{
(void)sender;

// if ( self.prefController == nil ) // this line should not be commented out
{
self.prefController = [ [ NSWindowController alloc ] initWithWindowNibName: @"PrefWindow" ];
};

[ self.prefController showWindow: self ];
}

But when I *not* comment out the if… line it works exactly once.

How can I convince my NSWindowController to keep its window?

Gerriet.




iOS - Debugging an uncooperative UIAlertController

Alex Zavatone
 

On certain iDevices, we have a UIAlertController that refuses to display the text of the only button, the OK button. This has been a problem for the past year and of course it only appears in the alert used for the user to complete registration.

Oddly enough, in the UIAlertAction the text is not nil, the button area is tappable, we are adding it to the alertController in thread 1 and on some devices, it just doesn’t appear.

Does anyone have any tips for debugging this type of situation? I have a reproducible case on one device now (iOS 9.3.5, iPad 2) and am about to start looking in to the view hierarchy to see what I can see.

Has anyone else seen this type of situation before?

Thanks in advance,
Alex Zavatone


Re: WindowController

Quincey Morris
 

On Jul 17, 2017, at 07:12 , Gerriet M. Denkmann <g@...> wrote:

it works exactly once

You haven’t really done “due diligence” with this problem description. What does “works” mean? That the window doesn’t reappear after it’s made to disappear?

When you call that action method again, is self.prefController nil or not? Or does the “showWindow” not make the window visible? Does the action method get called at all, after the first time? What kind of object is “self”? How is the “prefController” property declared? How did you hide the window (orderOut: or close)? Is it a NSWindow or a NSPanel?

A window controller has an owning reference to its window, so it should be impossible for the window object to disappear while the controller still exists, even if the window is closed. However, the semantics of the NSWindow “close” method are unclear, and it may be that you can’t show the window again afterwards, without creating a new window (or using orderOut: instead).


Re: Game Center Multi-Player Question

Quincey Morris
 

On Jul 17, 2017, at 07:21 , Dave <dave@...> wrote:

As far as I can see, this approach won’t work with Game Centre, does anyone know if this is correct?

That’s correct. Game Center doesn’t provide any kind of “server side” logic, which is how you’d naturally want to implement AI players.

The only thing you can do with a Game Center game (other than implement your own server elsewhere, of course), is to put the “server” logic in a device or devices. You can, for example, elect one of the real player devices to supply the logic of all of the AI players. Or, you can replicate the logic in all devices (by using a seeded pseudo-random-number generator and deterministic behavior) so that each real device knows what all AI players will “do”. Something like that.

The downsides are that this is not terribly secure (a determined hacker can at least find out what the AI players will do in advance), and it complicates matchmaking. (It may also make your app bigger and slower, if the AI computations are significant.)


Re: Game Center Multi-Player Question

Pascal Bourguignon
 


On 17 Jul 2017, at 19:40, Quincey Morris <quinceymorris@...> wrote:

On Jul 17, 2017, at 07:21 , Dave <dave@...> wrote:

As far as I can see, this approach won’t work with Game Centre, does anyone know if this is correct?

That’s correct. Game Center doesn’t provide any kind of “server side” logic, which is how you’d naturally want to implement AI players.

The only thing you can do with a Game Center game (other than implement your own server elsewhere, of course), is to put the “server” logic in a device or devices. You can, for example, elect one of the real player devices to supply the logic of all of the AI players. Or, you can replicate the logic in all devices (by using a seeded pseudo-random-number generator and deterministic behavior) so that each real device knows what all AI players will “do”. Something like that.

The downsides are that this is not terribly secure (a determined hacker can at least find out what the AI players will do in advance), and it complicates matchmaking. (It may also make your app bigger and slower, if the AI computations are significant.)

I would associate a small number of AI with each player. 
This way, if a player quits, only a few AIs are killed.


-- 
__Pascal J. Bourguignon__




Re: WindowController

Gerriet M. Denkmann
 

On 18 Jul 2017, at 00:30, Quincey Morris <quinceymorris@...> wrote:

On Jul 17, 2017, at 07:12 , Gerriet M. Denkmann <g@...> wrote:

it works exactly once
You haven’t really done “due diligence” with this problem description. What does “works” mean?
“Works” means that showWindow does indeed show a window.

That the window doesn’t reappear after it’s made to disappear?
Yes. After the red button got clicked on the PrefWindow, it never will appear again.


When you call that action method again, is self.prefController nil or not?
The first time prefController is of course nil.
The next time it is not.

Is there a corresponding line of code that sets self.prefController to nil when the window is closed?
No.

Or does the “showWindow” not make the window visible?
Exactly: this is the problem.

Does the action method get called at all, after the first time?
It gets called.

What kind of object is “self”?
App delegate.

How is the “prefController” property declared?
strong

How did you hide the window (orderOut: or close)?
Clicking the red button.

Is it a NSWindow or a NSPanel?
Same problem for both.


Have you made sure the “release on close” checkbox isn’t set in IB?
It is not checked.


(But do you really want the prefs controller to hang around when it’s closed? Seems like a waste of memory to me.)
Yes. But loading the window again would be a waste of Cpu time.
Not sure what is worse.

Kind regards,

Gerriet.


Localised Windows

Gerriet M. Denkmann
 

I have two apps: one in Objective-C, the other one in Swift.

Both have:

PrefWindow.xib
PrefWindow.xib (Base)
PrefWindow.strings (German)


The problem is:

1. The Objective-C version just ignores PrefWindow.strings.
2. The Swift version prints (whenever it should show the window):

… [strings] ERROR: QvC-M9-y7g.title not found in table PrefWindow of bundle CFBundle 0x100d02860 </System/Library/Frameworks/AppKit.framework> (not loaded)


But PrefWindow.strings (German) has:
/* Class = "NSWindow"; title = "Preferences"; ObjectID = "QvC-M9-y7g"; */
“QvC-M9-y7g.title" = "Einstellungen";

What am I doing wrong?

Gerriet.


Re: WindowController

Quincey Morris
 

On Jul 17, 2017, at 11:27 , Gerriet M. Denkmann <g@...> wrote:

The first time prefController is of course nil.
The next time it is not.

I would suggest that you look in the debugger at whether the window controller *has* a window the second time around. (Note that the “window” property automatically loads the window if necessary, which means that looking can sometimes affect what you’re looking at, though I suspect not in this case.)

If it has a window, try looking at its size and frame, whether it is hidden, etc.


Re: WindowController

Gerriet M. Denkmann
 

On 18 Jul 2017, at 03:35, Quincey Morris <quinceymorris@...> wrote:

On Jul 17, 2017, at 11:27 , Gerriet M. Denkmann <g@...> wrote:

The first time prefController is of course nil.
The next time it is not.
I would suggest that you look in the debugger at whether the window controller *has* a window the second time around.
It never has. Even after the first time where showWindow will succeed.

Kind regards,

Gerriet.


Re: WindowController

Quincey Morris
 

On Jul 17, 2017, at 14:08 , Gerriet M. Denkmann <g@...> wrote:

It never has. Even after the first time where showWindow will succeed.

This is — in some sense — impossible. There is a window. (You can see it.) Either the debugger is lying to you, or the window is unrelated to the window controller. Whichever it is, it’s worth investigating further.

BTW, in your XIB file for the preferences window, did you leave “Visible at launch” checked? It shouldn’t be, if you’re using a window controller, but OTOH I can’t see it having this result if you did.

61 - 80 of 1460