Remove from parent problem

Jo3m

  • Posts: 22
Hello, How to use correctly: "remove from parent" (?)

I provide the code of my problem to illustrate the use I make of it.

The routine is programmed in an actor. The principle is to create an "image", to copy the image of the actor, to change a chosen color, to display the result, then to delete the image via the command "remove from parent" and to restart the operation to be able to create a succession of color changes in the image.

But as soon as I introduce the "remove from parent" command, the program will scrach ...

I am very much annoyed.

Thank you, if you can tell me how to use this order PROPERLY? Thank you.

designpeg

  • *
  • Posts: 699
Hi, try creating an image instance variable, then setting it to an instance of the image, then attaching the variable to your actor, then use the remove image from parent block to remove the image instance VARIABLE.

Jo3m

  • Posts: 22
Hi, try creating an image instance variable, then setting it to an instance of the image, then attaching the variable to your actor, then use the remove image from parent block to remove the image instance VARIABLE.

Hello, thank you for the response. Look at my code, is not it what I already do? I create an image instance in my object and I destroy that instance later.

Do you mean that this action must be coded "outside" the object? In the main mainloop?

Thank you.

designpeg

  • *
  • Posts: 699
Hi, your code does create an instance and attaches it, but there's no reference to use to remove it later. you need to create an attribute, set it to an  instance, then attach the attribute.

I've attached a screenshot. Also, i've found that after you remove the image it's good to use the code block with  _yourImage.dispose();     this purges the original image from memory, it may be different in the latest version, but the last version didn't clear up after images are not shown, and my games would crash after running out of memory filled with images that I was changing. ( in the example shown the code would be _myimage.dispose(); )

rodolfovs

  • *
  • Posts: 137
Hello, there are two aspects of your code that I understand that can be problematic.

The first is that you are using these blocks of code in the "when drawing" tab. This tab repeats indefinitely if there is no limiting condition, so from what I saw in your code whenever "tour" is different from 0 it will repeat the codes from the otherwise tab.

The second point is that the block "otherwise" will remove from parent since the "Im Affiche" has been created. If you are requesting remove from parent without having defined the image for "Im Affiche", it will always give an error.

Hope this helps.

Jo3m

  • Posts: 22
Great ! Thank you very much !

Join my example.  Run windows ok and html5 ok 60fps

BUT (!)

but by soliciting memory (mem inconstant) while staying at 60fps.

The tip "code: Image0.dispose" does not work. Too bad maybe the performance would be better.

This method is to prepare a pixel management function for the object (like shaders but based on an old technique) I will explain later (in another subject).

How does one add "a game html5" in his profile ??? I wanted to add my functional example but I do not find way to put it online in my profile as for you other creators.

Thank you !

designpeg

  • *
  • Posts: 699
Hi, the swap with hue block will impact on performance too. Some filters are hardware accelerated on some platforms, eg I found a huge difference in performance between tint and hue filters.  As for the dispose code, I  did a test game where I exported full frames from a video as pngs and dumped over 3000 of them in the extras folder. Then the  game loaded one, attached an instance to the screen each frame, (removing the previously attached frame first). Without disposing the image my ipad would crash after about 12 frames as it filled it's memory with bitmap data. With dispose() it would happily run through all 3000. The really cool part was that since the images are loaded on the fly, the load time for the scene isn't effected by the number of images in the folder. I ended up using this technique in my game - I have a large number of background images and i scroll around loading chunks of the background, which means there's no need to change scenes.

Jo3m

  • Posts: 22
Animated Gif attached.

Indeed, it is clear that the memory increases continuously during execution.

Your trick of clearing the memory cache could help me, but I have to apply it correctly (it does not work for now).

This is an object whose image here has 4 colors. Later, I'd like to use this technique to do pixel processing (per pixel) but support multiple pixels of the same color on the fly. Rather than browse all the pixels of an image.



I hope, with this method, to set up a system that manages a similar normals map (or bump mapping) to manage the luminous direction on the objects.

And for other effects.

I will develop the method and share it. Thank you for helping me to optimize later if you're interested.

Un grand MERCI !  :)

« Last Edit: June 14, 2019, 11:37:11 am by Jo3m »