|
I don't think SKLabelNode is meant to be used like you're trying to, it's intentionally very simple. If memory serves, they said right in the WWDC 2013 SpriteKit session video that you should use UILabel and only use SKLabelNode for simple text that doesn't change often. The impression that I got is that it's literally doing behind the scenes what you're doing. SpriteKit seems nice at first, and then you try to actually use it and notice some glaring omissions and welp, back to Cocos2D. edit: I've got it working in a UIView with plain old Core Graphics. Take out the line where you set the fill color, and make sure the line where you're setting the color in the text attributes is actually getting run. edit 2: here, a working demo. Written in Objective-C instead of Swift, and doesn't do any of the SpriteKit stuff. It just draws colored text into a CGContext Doc Block fucked around with this message at 09:29 on Jul 21, 2014 |
# ? Jul 21, 2014 07:06 |
|
|
# ? Jun 1, 2024 06:25 |
|
I remember trying to learn Objective C once, ages ago. Tried to make an app with it, tried to learn everything on my own via Ray Wenderlich tutorials, and I had barely finished learning C. About a year's worth of coding experience. Christ, that sucked. Might come back to it now though.
|
# ? Jul 21, 2014 07:19 |
|
JakeLiebenow posted:I remember trying to learn Objective C once, ages ago. Tried to make an app with it, tried to learn everything on my own via Ray Wenderlich tutorials, and I had barely finished learning C. About a year's worth of coding experience. Took me until the third time through to get it. Learning how to make BankPayroll.app for the nth time made me want to die.
|
# ? Jul 21, 2014 14:43 |
|
Axiem posted:If you want multiline text, you either have to hack a container that actually creates an SKLabelNode per line and groups them together This is what I did and I hate it.
|
# ? Jul 21, 2014 15:34 |
|
Why can't you just whip up a UIView with a transparent background and layout whatever you want, then render that to an image? It can be offscreen and just re-used whenever the text changes. Would the performance be horrible? I have some code for that lying around if you need it. For that matter, I haven't used SpriteKit so I have no idea if you can later UIKit over it directly or what.
|
# ? Jul 21, 2014 16:36 |
|
Yes, that's what you're supposed to do with SpriteKit: use UIKit for the game's UI. SKLabelNode just renders the text to a texture and then uses that as a sprite, which is why Apple cautions against using it for anything that changes: every change means it has to recreate the texture. Use UILabel if you want styled, multi-line text. Or see my edit to my previous post for how to do text drawing with Core Graphics.
|
# ? Jul 21, 2014 16:48 |
|
If you'd like to display multiline text, see DSMultilineLabelNode. There are other multiline implementations out there as well.
|
# ? Jul 21, 2014 17:28 |
|
I'm not at a computer with Xcode at the moment, so I'll have to check out that UIKit code later. However, it's sounding more and more like perhaps SpriteKit isn't the right way to do my game. A lot of the game is going to be dealing with menus and text, as opposed to doing things with physics. I had originally done SpriteKit because well, game, and also because when I do transition things to being actual images for the buttons and such, I figured SpriteKit would handle that efficiently. But if I end up needing to do custom UIView logic to get something as simple as a bit of text on the screen, I might as well transition the entire thing to UIViews (/UIKit in general). Or is that also a bad idea when it comes to building a lot of custom stuff for a game aesthetic?
|
# ? Jul 21, 2014 17:35 |
|
Axiem posted:Or is that also a bad idea when it comes to building a lot of custom stuff for a game aesthetic? Core Graphics happens on the CPU, but CALayers will generally transform stuff on the GPU (such as transform, bounds, position). If you're doing more manipulation than redrawing, then you can probably get pretty far with those, but deep and complex UIView hierarchies get bogged down a lot sooner than CALayer hierarchies.
|
# ? Jul 21, 2014 17:44 |
|
Doctor w-rw-rw- posted:Core Graphics happens on the CPU, but CALayers will generally transform stuff on the GPU (such as transform, bounds, position). If you're doing more manipulation than redrawing, then you can probably get pretty far with those, but deep and complex UIView hierarchies get bogged down a lot sooner than CALayer hierarchies. And SpriteKit uses CALayer while UIKit uses Core Graphics, I take it? (View stuff has never been my strong suit in any language) At least with the way I've architected things so far, I should be able to transition some things to using UIKit (in particular, in the places where I intend on having text from a UI perspective), and can figure out how performance is going down the road. I want to avoid premature optimization for things I have no idea of the efficiency of.
|
# ? Jul 21, 2014 18:02 |
|
Axiem posted:And SpriteKit uses CALayer while UIKit uses Core Graphics, I take it? (View stuff has never been my strong suit in any language) SpriteKit is just a wrapper around an open-source game engine. Probably uses OpenGL or something. Core Graphics is just an API for drawing to a drawing context that's abstracted out, and being able to output it to vector graphics to PDF, or PNG, or whatever. UIKit as I understand it is basically UIViews (CALayers + event handling) + a whole lotta keyboard/text plumbing, and integration with UIViewControllers and more advanced constructs that need the capabilities of UIViews. No idea what your goals or ultimate ideas are but just do what you're comfortable with or think you can plausibly learn. (E: clarity. also vvv is better-stated) Doctor w-rw-rw- fucked around with this message at 18:23 on Jul 21, 2014 |
# ? Jul 21, 2014 18:10 |
|
Just use Cocos2D. SpriteKit's API was heavily "inspired" by Cocos2D, but Cocos2D is a lot more mature, doesn't have the glaring omissions that SpriteKit does, and you can do everything in Cocos2D instead of a weird SpriteKit/UIKit hybrid (even custom drawing). Also, Cocos2D V3 has very good integration with Chipmunk2D, which IMHO is a better and faster 2D physics engine than Box2D (which is what SpriteKit uses under the hood). And you can use SpriteHelper (or whatever it's called), which is like Interface Builder but for Cocos2D, and it also helps you build animations and physics. Edit: Cocos2D uses OpenGL, so all drawing happens on the GPU. UIKit uses Core Graphics and Core Text to draw the individual views on the CPU into CALayers (which cache the result), with Core Animation drawing and compositing the CALayers on the GPU. SpriteKit probably uses OpenGL. Doc Block fucked around with this message at 18:24 on Jul 21, 2014 |
# ? Jul 21, 2014 18:14 |
|
Probably a better way to phrase what I mean is this: I'm going to migrate to just doing a UIKit interface for now, while I focus on making the gameplay and gameloop better. Once I get that into a better state, I can evaluate my options a little more for e.g. Cocos2D and such (and maybe find an artist willing to help out, because I'm terrible at art). Part of the advantage to a true MVC/MVP architecture is that so long as I have a clearly defined interface for my view, I can relatively easily switch it out down the line. Doing a switch to UIKit will give me a chance to re-evaluate that interface and make sure it's doing the right thing. Besides, learning a little more about UIKit can't particularly hurt with knowledge for future apps. Ultimately, while I want to make a game, I'm also having fun just digging in and learning Swift, design patterns, and Cocoa Touch. Thanks for the advice and knowledge. It's definitely helpful. The thing that baffles me is that it doesn't look like a whole lot of work was done in the past year to cover up the glaring omissions that say, Cocos2D covers.
|
# ? Jul 21, 2014 18:28 |
|
Doctor w-rw-rw- posted:SpriteKit is just a wrapper around an open-source game engine. What engine is it?
|
# ? Jul 21, 2014 18:53 |
|
Nipplebox posted:What engine is it? AFAIK - and I don't do games programming, so my knowledge is very superficial - it either has an API borrowed from or an API wrapping Cocos2D's. But I have spent literally zero time reading through docs for either project so I could be totally off base here, as I'm just recalling something that another developer told me. E: vvvv UIKit Dynamics uses Box2D under the hood, but with regards to Cocos2D, you're probably right in that it's similar because it borrowed the same ideas to solve the same problems. Doctor w-rw-rw- fucked around with this message at 01:40 on Jul 22, 2014 |
# ? Jul 21, 2014 23:18 |
|
What I've seen of the API is extremely similar to cocos2d but they solve the exact same problem so that was inevitable whether it was their goal or not. It's under the MIT license anyway so no one can get mad even if they did use it.
|
# ? Jul 21, 2014 23:43 |
|
It definitely draws ideas from Cocos2D, but this is the first I've heard of it being a wrapper around Cocos2D. My understanding is that, at most, it uses Box2D.
|
# ? Jul 22, 2014 01:29 |
|
Yeah, it's just a case of the SpriteKit API being similar to Cocos2D's. There are enough differences and shortcomings in SpriteKit that it probably isn't a mere wrapper.
|
# ? Jul 22, 2014 01:38 |
|
I can't believe I'm asking this, but where are the Provision Profiles listed on the Settings screen? I never had trouble finding these, or maybe it has disappeared somehow. Xcode is saying that it can't find any on the device, but if they expired I remembered them still being listed. Kinda stumped how this all happened. Update - Looks like it doesn't show up as a section in General if you don't have any valid non-expired profiles! LP0 ON FIRE fucked around with this message at 14:57 on Jul 23, 2014 |
# ? Jul 23, 2014 14:45 |
|
When your application is in background, background tasks can run for about 60 seconds. When your application is in foreground, background tasks can run for 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368 seconds (it's DBL_MAX)
|
# ? Jul 25, 2014 15:11 |
|
Is iTunes Connect broken / not working for anyone else? The website is in endless "your session has expired" cycles, and none of my apps in development can connect to game center. I have 3 accounts and they all are having the same issues. Apple's system status thing says everything is fine...
|
# ? Jul 25, 2014 16:47 |
|
Lumpy posted:Is iTunes Connect broken / not working for anyone else? The website is in endless "your session has expired" cycles, and none of my apps in development can connect to game center. I have 3 accounts and they all are having the same issues. Apple's system status thing says everything is fine... I'm seeing the same, as is one of my colleagues. It's working fine for the guy in between us.
|
# ? Jul 25, 2014 17:05 |
|
First question when I hear of things like this: did you try it with Safari?
|
# ? Jul 25, 2014 18:11 |
|
Yes, after it wasn't working in chrome. Safari didn't help. Then suddenly it started working again. Once again, posting in a thread magically fixes things!
|
# ? Jul 25, 2014 20:25 |
|
So I've been teaching myself this stuff as-needed for work and personal projects, but I'm thinking I should start thinking of this as a career option. Are there any primers on things that I should know, but might not pick up on my own? Obj-c-specific good practices, design principles, nooks and crannies, etc?
|
# ? Jul 25, 2014 23:04 |
|
I'm making a stupid screensaver that draws rects with NSBezierPath, however when I draw rects on top of each other they don't always cover up the rect underneath. Sometimes drawing a black rect over a red one will leave the 4 corner pixels still visible. Sometimes it does nothing at all. It seems to be related to the current screen resolution (if it's scaled or not), and it works fine on my rmpb screen at the highest scaled resolution. Since it's a screensaver I don't set up the window I'm drawing into at all, I just start doing this in the AnimateOneFrame method:code:
|
# ? Jul 27, 2014 03:42 |
|
Ninja Rope posted:I'm making a stupid screensaver that draws rects with NSBezierPath, however when I draw rects on top of each other they don't always cover up the rect underneath. Sometimes drawing a black rect over a red one will leave the 4 corner pixels still visible. Sometimes it does nothing at all. It seems to be related to the current screen resolution (if it's scaled or not), and it works fine on my rmpb screen at the highest scaled resolution. Since it's a screensaver I don't set up the window I'm drawing into at all, I just start doing this in the AnimateOneFrame method: Are you drawing to the center point of each pixel (x+0.5) or directly on it? My first guess is maybe interpolation artifacts. Another wild guess, but you could also try drawing to your own backing buffer of fixed resolution then scaling for display to get deterministic behavior. If the display is scaled, are you doing the scaling or is the OS? I wonder if the draw commands are being scaled before drawing (rather than scaling the resulting bitmap). In theory scaling the draw commands would yield better results but I can see that producing some jitter if you're trying to do sub-pixel precise overdraw. I'm not an expert on this stuff though, so YMMV.
|
# ? Jul 27, 2014 03:53 |
|
I'm learning Objective C blocks and while I generally understand how to use them, I'm struggling to figure out how to use a block that takes parameters.code:
|
# ? Jul 27, 2014 16:47 |
|
PiCroft posted:I'm learning Objective C blocks and while I generally understand how to use them, I'm struggling to figure out how to use a block that takes parameters. http://fuckingblocksyntax.com e: Parameters go in parentheses between ^ and { when calling a block
|
# ? Jul 27, 2014 17:00 |
|
Objective-C code:
|
# ? Jul 27, 2014 17:08 |
|
Thanks guys that makes sense. Here's my completed code: code:
code:
|
# ? Jul 27, 2014 17:25 |
|
What are you expecting to happen? edit: in your block, you're printing a and b instead of _a and _b. So the block captures the main() function's a and b variables, and prints them out when called instead of the _a and _b variables that are passed to it. edit 2: your method name is non standard and kinda confusing. If you have a method named -performWithBlock then the first parameter should be the block. Like this: code:
Doc Block fucked around with this message at 18:18 on Jul 27, 2014 |
# ? Jul 27, 2014 18:08 |
|
Doc Block posted:What are you expecting to happen? In this case, nothing except for the log to output the messages in the correct order, which is the message in the performWithBlock(), then the message in the block itself. If I had forgotten to add the block call (which I did at first) then it would print the message in peformWithBlock but the block would be ignored. e: per your edit, yeah I missed that. Thanks for pointing it out. e2: I read on stack exchange (can't find the topic anymore) that you should put block parameters last in the list. I can't remember if they said it was a requirement or just a convention but that's why I put the block last and the ints first. PiCroft fucked around with this message at 18:24 on Jul 27, 2014 |
# ? Jul 27, 2014 18:17 |
|
See both of my edits. If you're just printing the numbers, there's no need to pass them as pointers. code:
Doc Block fucked around with this message at 18:31 on Jul 27, 2014 |
# ? Jul 27, 2014 18:28 |
|
PiCroft posted:e2: I read on stack exchange (can't find the topic anymore) that you should put block parameters last in the list. I can't remember if they said it was a requirement or just a convention but that's why I put the block last and the ints first. It's not required, just that it can make the method call cleaner. But then you should rename the method. Maybe -performTestWithNum1:(int)num1 num2:(num2) testBlock:(TestBlock)testBlock
|
# ? Jul 27, 2014 18:34 |
|
PiCroft posted:e2: I read on stack exchange (can't find the topic anymore) that you should put block parameters last in the list. I can't remember if they said it was a requirement or just a convention but that's why I put the block last and the ints first. Passing block-typed parameters at the end is just a convention. Swift has a bit of syntactic sugar for "trailing blocks" that makes this nicer, but in general the idea of putting a block parameter at the end is that it's more aesthetic when the block itself is inline with the call.
|
# ? Jul 27, 2014 18:34 |
|
I understand guys, thanks for the help
|
# ? Jul 27, 2014 18:43 |
|
hiya folks, i'm stumbling in the dark here and there's a lot of conflicting information out around - i was wondering if somebody could perhaps give me the straight dope on how to programmatically add constraints to a view so as to make it always match the frame of its parent view?
|
# ? Jul 29, 2014 10:22 |
|
Also, did the interactive transitions api just change in iOS 8 β 4? I can't get my transitions working again for the life of me...
|
# ? Jul 29, 2014 13:30 |
|
|
# ? Jun 1, 2024 06:25 |
|
Can someone confirm that with C11 (not C++11, but C11) enabled*, that this code errors with "Documentation error!"?C code:
*Xcode project settings: C Language Dialect, select c11 or gnu11 EDIT: Nope, build system just refused to pass along the build flag that enabled gnu11 for some reason, ignore me. Doctor w-rw-rw- fucked around with this message at 22:45 on Jul 30, 2014 |
# ? Jul 30, 2014 22:17 |