I've tried to search on the internet for a method that can get a specific node from the scene. I've seen a lot of methods, but it doesn't give me a clear answer.
I've have build a scene in SpriteBuilder from Cocos2D. This is how the MainScene.ccb looks like:
If needed: This is how Player.ccb looks like:
I'm trying to get the player 'object' in Xcode after I published the project. I've tried to use CCBReader, but I can't find any useful method (unless I missed it). Also I've tried so use self.children, but I don't know how to continue any further with that.
Can you help me out? At the end, I want to get the position of the player.
Thanks!
By the way, I'm a beginner in Swift, so don't expect that I know all of the terms.
When you add nodes (sprite) to your sprite builder project, make sure it is selected, then on the right, click theorem code connections tab. In the 'Doc root var' type your variable name in the box.
When you load Xcode select the file that loads the scene from sprite builder and you can then declare a variable in this file with the same name you gave it in sprite builder. You will then be able to use that node (sprite) whenever you want and access it's properties.
Related
Everything I have found, every one says this cant be done.
I studied in fullsail university and they taught me how to do this so I know without a doubt it can be done. No one just knows how and assumes it can't.
Basically, when in XCode-story board, I would add constraints to a view and everything is all blue and perfect. From there, if you click, hold a drag, the view to another position then all of the constraints will turn orange. (Not RED because the constraints are still good it just simply needs to snap back into place..)
When in school my teacher taught me a quick key short cut that you press and everything snaps back into place and its all blue again. It has been a while since I have coded and i am just now getting back into it again and i just cant remember what that shortcut was.
I hope someone out there knows how to do this. Maybe any fullsail graduates?
Your responses are greatly appreciated.
I figured it out.
option + CMND + '='
What you're looking to do is referred to as "Update(ing) Frames."
The quick command is indeed option-command-equals
The command can also be reached from the bottom menu of a storyboard.
This link may change in the future but check out the Auto Layout Guide. Specifically reference the "Resolve Auto Layout Issues Tool" section.
I have made some games in Xcode using spritkit(Swift); however, never with levels. I do not really understand how you make different levels in spritekit. It does not seem like a good idea to make different levels in different "GameScenes", or is it? I would really appreciate some help with this. Thanks in advance!
I understand this is very late but I'd like to help future programmers. The way I was taught to add levels in a way similar to how Angry Birds has its levels. What you do is create a new .sks file by going in Xcode to
File => New => File...
When the popup appears select SpriteKit Scene. Save its name to whatever you feel like. At this time, take a break to make your level alone in the new SpriteKit Scene. Here's an example for a game similar to Angry Birds:
[Required] Now, to be precise in where you want the level to be, go to your GameScene.sks file and add a new node to the place you want your level to be. In the Attributes inspector, name the node to levelNode.
Now, go to your GameScene.swift file. Go to the top of the file and add
var levelNode:SKNode!
Then navigate to your didMoveToView function and add the following code to the beginning of it:
levelNode = self.childNodeWithName("levelNode")
After the that line of code, add this:
let resourcePath = NSBundle.mainBundle().pathForResource("WhateverYouNamedYourLevel", ofType: "sks")
let newLevel = SKReferenceNode (URL: NSURL (fileURLWithPath: resourcePath!))
levelNode.addChild(newLevel)
Good Job! You have just created your first level!
Hope this helped, feel free to leave an upvote! :p
Hi I have updated my Xcode and iOS . In the iOS 9 they have made some changes in HomeKit. In that they have by default added some predefined scenes. like HMActionSetTypeSleep,HMActionSetTypeWakeUp ... When I click on that scene in HMCatalog app it throws error that no actions in the actions. Could any one please tell me how to execute the HMActionSetTypeWakeUp type built in scenes.Thank you for your valuable time. Please let me know if I am not clear.
The 'Scenes' by itself are HMAction aggregators, i.e. HMActionSets. You need to add actions to the HMActionSet in order to execute, or make the action set/scene do anything.
For e.g., I'd like to set desired thermostat temperate to 22 degree Celsius when I execute the Wake Up or Good Morning pre-defined scene under a HMHome.
In order to do so, you would create an HMAction (or more precisely, HMCharacteristicWriteAction - a subclass of HMAction), that writes the value 24 to the thermostat's desired temperature HMCharacteristic.
Once the HMAction is created (and you can create multiple such actions), add that HMAction to the predefined scene. Look at the iOS api for the exact api calls to do so.
In the HMCatalog app, take a look at the 'ActionSetCreator' class.
Also, you can see this action by adding HMActions in the HMCatalog itself. Drill down to a thermostat (or any other homekit paired service). Change the values of some HMCharacteristics under the HMService, then drill back up and save your scene (I may be off from the exact screen by screen details, as writing this out of memory on an airplane seat, but you get the point - hopefully).
Once you have (any) HMActions listed under a pre-defined scene - try saying the name of the scene to Siri (or you can simply execute it by pressing on the scene on HMCatalog).
If the thermostat (or other HomeKit service) is properly paired, you should see your state problem resolved.
I would like to add Command's to a View's pulldown-menu (the triangle-shaped button in the upper right corner that the "Problems"-View in Eclipse also has).
Can anyone point me in the right direction how to do this declaratively in plugin.xml?
I found a tutorial that used a viewContribution (extension point org.eclipse.ui.viewActions), but unfortunately using this extension point i can only add Action's to this menu.
The functionality i wish is actually quite similar to the Problems-View (Showing Compiler-Errors and -Warnings in Eclipse):
I want to filter records within my View according to an Entry chosen in the pulldown-menu of the View.
For an example configuration you can use the implementation of the Problem View itself. It uses the org.eclipse.ui.menus extension point to contribute that menuItem through a dynamic contributor. You can check the details in the plugin.xml of the org.eclipse.ui.ide plugin. Look for the usage of the class org.eclipse.ui.internal.views.markers.FiltersContribution. In its "getContributionItems()" method it returns menu contributions dynamically each time the menu is to appear. Of course, doing it this way is not exactly declarative. For that try reading the guide at http://help.eclipse.org/indigo/topic/org.eclipse.platform.doc.isv/guide/workbench_cmd_menus.htm (you should use your command instead of the global ones, of course)
Hope it helps!
I'm trying to create a very simple selection list widget based on NSOutlineView. However, I'm having a hard time figuring out how to display an icon and a label right next to it, which is really the expected behavior in all the mainstream implementations of that kind of widget out there (iTunes, mail, Finder,...).
So far I am just binding two separate cells, but then when I'm expanding the tree, the icon cell grows larger and a gap appears between the icon and its accompanying label. I know I can probably overcome this problem by extending NSCell and provide a custom class, but as what I'm trying to achieve is really the standard thing, I can't be resigned to accept that there isn't a simpler solution.
Candide
Sadly, there isn't a 'text and icon' cell that you can just use, fresh out of the box as you would like. However, when I was working on a project, I found that Apple released some sample code that implements this, since it is such a common idiom.
This can be found here, specifically ImageAndTextCell.h/m
It can help teach you about UI customization by reading through this example, but scratching that, just dropping the ImageAndTextCell straight into your project should do just fine.
You need to create ImageAndTextcell to combine text and icon..
you can create ImageAndTextcell like this Sample Project