What's the safest way to attach some ImageSheets to another one?

Hi,

I have a table which is a ImageSheet instance and it doesn’t move. I edited it’s physic size and use it to detect collision. What I want to do is to attach some more ImageSheets for aesthetics but I need to increase and decrease them based on properties of that base ImageSheet.

I know if the base object was Display Image, I would turn it into Display Group but first of all, I have a very bad memory of doing that from months ago as it broke my physic collision detection and never could get it to work and also we are talking about several ImageSheets here, not display groups.

I suspect to make the main object into Display Group and then attach the main image as ImageSheet to it and then attach the new ImageSheet as well but first of all I don’t know how to do that and if it’s allowed at all and second, don’t know how to make the it work without breaking the game of what I currently have, like how to make the main object’s physic to work on collisions.

(I can’t remember clearly what was the problem of making a Display Image into Display Group but it was physic related)

Please be as descriptive as you can on your reply as I’m new to Corona.

Thanks. [import]uid: 206803 topic_id: 37377 reply_id: 67377[/import]

Hi Aidin,
I think the “breaking collisions” issue was that you put images into a display group then tried to move that group independently of others. This will mess up physics collision.

Pertaining to your main issue though, do you basically want to add “parts” ( new images) to another core image, and then make its physics body appropriate for the added parts? For example, you have a “body” part, then you want to add “arm” and “leg” and make those physically aware too?

If so, you can do either of these:

  1. Add the new parts as separate physics objects and attach them to the “core body” using weld joints.
  2. Remove and then re-create the entire physics body to make it appropriate to the new overall construction.

Brent [import]uid: 200026 topic_id: 37377 reply_id: 145609[/import]

Hi Brent,

Thanks for the reply. In fact, no. Those attached ImageSheets will not have physic, they are just for aesthetics and help gameplay visually.

My main problem is how to attach ImageSheets to one main ImageSheet so I can control which animation they should be playing by calling methods on them from the main ImageSheet object.

Thanks again and appreciated. [import]uid: 206803 topic_id: 37377 reply_id: 145631[/import]

Hi Aidin,
Well, you can’t “fuse” two image sheets together during the app run.

You can create sprites that utilize multiple image sheets (they contain sequences that come from different sheets), but you still can’t “mix” sequences across different sheets.

For example, you CAN do this, with one sprite:
monsterEating1 = sequence from sheet “monsterEating”
monsterEating2 = another sequence from sheet “monsterEating”
monsterRunning = sequence from sheet “monsterRunning”
etc.

But you CAN’T do this:
monsterCombined = sequence with 4 frames from “monsterEating” and 4 frames from “monsterRunning”.

Does that make sense? I think you’ll just have to cleverly combine the visual elements somehow, using different sheets. Without seeing your actual game design in action, it’s a bit difficult to know what you’re ultimate goal is with this.

Best regards,
Brent [import]uid: 200026 topic_id: 37377 reply_id: 145649[/import]

Thanks Brent,

I don’t want to load their texture from one single image sheet. In fact I don’t care about that now. I just want the main object have (or contain) the collection of the other image sheets so it can give them commands on which animation to play. Those “attached” ones have their own sprite sheet.

I basically need the main object, let’s call it monster, to “have” several image sheets, let’s call these tongues. In fact those tongues have their own class and are created via a constructor method so I can call method calls upon them to change their animation. But what animation they should play or how many tongue we need to show depends on it’s owner, monsters, that’s why I need to put tongues inside each monster so they can see what and how they should behave internally.

To not get stuck at keep going, I did all this via a tongue manager class that has references from my monsters and handles tongue’s behaviors but architectural-wise it’s wrong and they should be inside the monsters themselves.

Hope it’s clear.

Let me know if you need more clarification on this. [import]uid: 206803 topic_id: 37377 reply_id: 145672[/import]

Hi Aidin,
I responded to your other post (on desaturating an image), and this seems related. You might really want to consider following the tutorial by Omid Ahourai about dynamically-generated sprites, as it seems this is very similar to what you’re doing in your game:

http://www.coronalabs.com/blog/2012/10/09/dynamically-optimized-sprite-sheets/

Brent [import]uid: 200026 topic_id: 37377 reply_id: 145799[/import]

Hi Aidin,
I think the “breaking collisions” issue was that you put images into a display group then tried to move that group independently of others. This will mess up physics collision.

Pertaining to your main issue though, do you basically want to add “parts” ( new images) to another core image, and then make its physics body appropriate for the added parts? For example, you have a “body” part, then you want to add “arm” and “leg” and make those physically aware too?

If so, you can do either of these:

  1. Add the new parts as separate physics objects and attach them to the “core body” using weld joints.
  2. Remove and then re-create the entire physics body to make it appropriate to the new overall construction.

Brent [import]uid: 200026 topic_id: 37377 reply_id: 145609[/import]

Hi Brent,

Thanks for the reply. In fact, no. Those attached ImageSheets will not have physic, they are just for aesthetics and help gameplay visually.

My main problem is how to attach ImageSheets to one main ImageSheet so I can control which animation they should be playing by calling methods on them from the main ImageSheet object.

Thanks again and appreciated. [import]uid: 206803 topic_id: 37377 reply_id: 145631[/import]

Hi Aidin,
Well, you can’t “fuse” two image sheets together during the app run.

You can create sprites that utilize multiple image sheets (they contain sequences that come from different sheets), but you still can’t “mix” sequences across different sheets.

For example, you CAN do this, with one sprite:
monsterEating1 = sequence from sheet “monsterEating”
monsterEating2 = another sequence from sheet “monsterEating”
monsterRunning = sequence from sheet “monsterRunning”
etc.

But you CAN’T do this:
monsterCombined = sequence with 4 frames from “monsterEating” and 4 frames from “monsterRunning”.

Does that make sense? I think you’ll just have to cleverly combine the visual elements somehow, using different sheets. Without seeing your actual game design in action, it’s a bit difficult to know what you’re ultimate goal is with this.

Best regards,
Brent [import]uid: 200026 topic_id: 37377 reply_id: 145649[/import]

Thanks Brent,

I don’t want to load their texture from one single image sheet. In fact I don’t care about that now. I just want the main object have (or contain) the collection of the other image sheets so it can give them commands on which animation to play. Those “attached” ones have their own sprite sheet.

I basically need the main object, let’s call it monster, to “have” several image sheets, let’s call these tongues. In fact those tongues have their own class and are created via a constructor method so I can call method calls upon them to change their animation. But what animation they should play or how many tongue we need to show depends on it’s owner, monsters, that’s why I need to put tongues inside each monster so they can see what and how they should behave internally.

To not get stuck at keep going, I did all this via a tongue manager class that has references from my monsters and handles tongue’s behaviors but architectural-wise it’s wrong and they should be inside the monsters themselves.

Hope it’s clear.

Let me know if you need more clarification on this. [import]uid: 206803 topic_id: 37377 reply_id: 145672[/import]

Hi Aidin,
I responded to your other post (on desaturating an image), and this seems related. You might really want to consider following the tutorial by Omid Ahourai about dynamically-generated sprites, as it seems this is very similar to what you’re doing in your game:

http://www.coronalabs.com/blog/2012/10/09/dynamically-optimized-sprite-sheets/

Brent [import]uid: 200026 topic_id: 37377 reply_id: 145799[/import]