on 09-07-2012 07:42 AM
Hi there,
This is another "coming from Cocos2d/UIKit" type question, but is there any type of "tag" system for retrieving added children. For example, in both cocos2d/uikit I can assign an integer tag such as 3 or OPTIONS_MENU_TAG to a sprite, add that to a scene with an addChild type function then retreive that child at any point by doing something like Sprite sprite = scene.getChildWithTag(OPTIONS_MENU_TAG)
What would be the equivalent in PSM? I don't need to keep each instance I want to retrieve up in the class members do I? I notice there are something called "tags" in relation to actions...
Thanks in advance for any help!
Solved! Go to Solution.
on 09-07-2012 09:37 AM
Hi CeeBee2012,
Thank you for your question. Unfortunately there ins't a way to do it as straightforward as you mentioned. Instead of tags, GameEngine2D Nodes have a 'Name' property, which although there are no checks to see if it's unique, could be used in a similar way. If you enforce the application of unique names to these nodes, you could use them as follows:
//....
sprite.Name = "sprite_lhs";
scene.AddChild(sprite);
//....
Node node = scene.Children.Find(child => child.Name == "sprite_lhs");
if(node != null)
Console.WriteLine("Found : " + node.Name);
else
Console.WriteLine("Nothing found");
Alternatively, if you know the position that they were inserted in the Children's List, then you could pick out the Node using its index.
Please let us know if you have any more questions.
Best regards,
James
on 10-07-2012 06:46 AM
Hey,
This would seem to achieve pretty much the same. Thanks
on 17-07-2012 06:08 AM
Thanks for your reply, I tried it for GameEngine scenes and it works like a charm ![]()
However it doesn't seem to work for UIToolkit scenes, as the Children list is implemented as a IEnumberable... I'm just hitting the documentation now to see how this works, but it seems a little odd that these two members are implemented slightly differently...
PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.
フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと
PSM DevPortalを一度ログアウトし、再度ログインしてください。


Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870