Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to better utilize display.newGroup() ?
Started by Benzeliden Sep 05 2017 11:43 AM

4 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Benzeliden

[GLOBAL: userInfoPane.html]
Benzeliden
  • Enthusiast

  • 79 posts
  • Corona SDK

Hi all,

I'm working on RPG game and want to customize my heroes look depending on items they wear. So I end up with this structure of groups (from back to front):

cloak group > body group > armor group > left hand group > right hand group

 

I dont use physics and want to add 1-2 sprites for each group

I see 2 scenarios here:

1) Each time I put new hero on battlefield (let say I have max of 5) I would create those 5 groups and insert them into scene group - so it would be 25 groups total

2) Create 5 groups and then use them for all my heroes

Is there any downsides of using 25+ display groups? Will it affect performance significatly more than solution 2 with 5 groups?



[TOPIC: post.html]
#2

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @Benzeliden,

Personally, I would use just 1 group for each character, and layer the parts (sprites) in a logical, non-changing way. If you insert objects into the group in the same way every time, you'll know which child of the group is which part, and then later you could swap them out for other parts.

 

Or perhaps better yet, add all parts to an image sheet and then "swap" which one appears based on one of the methods in this tutorial:

https://docs.coronalabs.com/tutorial/media/swapImages/index.html

 

Hope this helps,

Brent

 

 



[TOPIC: post.html]
#3

Benzeliden

[GLOBAL: userInfoPane.html]
Benzeliden
  • Enthusiast

  • 79 posts
  • Corona SDK

Hi @Benzeliden,

Personally, I would use just 1 group for each character, and layer the parts (sprites) in a logical, non-changing way. If you insert objects into the group in the same way every time, you'll know which child of the group is which part, and then later you could swap them out for other parts.

 

Or perhaps better yet, add all parts to an image sheet and then "swap" which one appears based on one of the methods in this tutorial:

https://docs.coronalabs.com/tutorial/media/swapImages/index.html

 

Hope this helps,

Brent

Swapping images is interesting, but I have sprite animation, so I should be able to swap whole sprite. So I think I will end up with 5 display groups and create new + remove old sprite to swap weapon\armor



[TOPIC: post.html]
#4

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Sure, that works fine too.

 

I'm not sure how complex your animations are, but if it's just a few frames of animation for each part, you could also "swap sequences" for the sprite... just set up all of your basic animation sequences using one sprite, then when you want to change the animimation, set the appropriate sequence... that would save all the steps of removing the object and putting a new object in its place.

 

Brent



[TOPIC: post.html]
#5

Benzeliden

[GLOBAL: userInfoPane.html]
Benzeliden
  • Enthusiast

  • 79 posts
  • Corona SDK

I'm afraid I will end up with large number of sequences like "idle1", "idle2", "idle3", "attack1" and so on. Also my sheet will be very big. So I'll better to stay with separate sheets

Thank you for quick answers, @Brent !



[topic_controls]
[/topic_controls]