GameEngine2D

Reply
Accepted Solution

Node "Tags"

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!

Please use plain text.

Re: Node "Tags"

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

 

PlayStation®Mobile Dev Team
Please use plain text.

Re: Node "Tags"

Hey,

 

This would seem to achieve pretty much the same. Thanks

Please use plain text.

Re: Node "Tags"

Thanks for your reply, I tried it for GameEngine scenes and it works like a charm :smileyhappy:

 

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...

 

Please use plain text.
This widget could not be displayed.
Announcements

Welcome to the PlayStation Mobile Developer Forums


This is a community for the discussion of technical topics with other developers and SCE engineers. Posting ideas/requests are also appreciated. Join the discussion!

PlayStation®Mobile開発者フォーラムでは世界中の開発者の皆様と一緒に、議論や情報交換が可能です。SCEも議論に参加し、皆様の開発をサポートします。アイデアやリクエストも大歓迎です。ぜひご参加ください。

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を一度ログアウトし、再度ログインしてください。






Recent News