April 23, 2017, 02:57:03 AM

Author Topic: HaxePunk 2.5.1  (Read 26506 times)

Matt Tuttle

  • Administrator
  • Sr. Member
  • *****
  • Posts: 309
    • View Profile
    • Matt Tuttle's Blog
HaxePunk 2.5.1
« on: February 13, 2014, 11:10:06 AM »
This is a patch release for 2.5. Here are some of the notable fixes.

Don't destroy graphic when Entity is removed
Added by andyli

This will allow to reuse Graphic objects between entities. It still may be necessary to cleanup on native targets though so use destroy() to free up any image memory.

Fixing BitmapText textWidth/textHeight and word wrapping when font size changes
Added by bendmorris

If you are using the new BitmapText class there have been several fixes/improvements made by bendmorris.

Pulled richText from FlashPunk into Text
Added by MattTuttle

If you've used the Text graphic class in FlashPunk you may have been missing the richText field. It has been ported over to HaxePunk and lets you colorize text output. Set a style with setStyle() and then use xml tags surrounding the text you want to modify.

Warning: Memory leak in Flash debug
There is a memory leak in Flash under debug mode. This is because OpenFL uses the -no-inline haxe flag by default in debug mode. There a pull request to fix this but it won't be available until the next release of OpenFL. If you are concerned about it, build your Flash projects in release mode for now.


There are a lot of fixes not covered here but they are no less important to making HaxePunk a better project. Thanks to everyone who created issues and contributed feedback. Your input is always appreciated!

scriptorum

  • Jr. Member
  • **
  • Posts: 67
  • Fast or slow zombies? Too late, you're dead.
    • View Profile
Re: HaxePunk 2.5.1
« Reply #1 on: February 26, 2014, 11:40:39 AM »
This is a patch release for 2.5. Here are some of the notable fixes.

Don't destroy graphic when Entity is removed
Added by andyli

This will allow to reuse Graphic objects between entities. It still may be necessary to cleanup on native targets though so use destroy() to free up any image memory.

I apologize if this sounds stupid, I'm having one of those brain fart days. What does this change require to support it? Do we need to do this to remove an entity now?

Code: [Select]
if(entity.graphic != null)
{
  entity.graphic.destroy();
  entity.graphic = null;
}
scene.remove(entity);

Also, why is this not required on non-native targets?

It seems like it would be better to restore the old behavior which the majority of us use and, for those who want it, add a shared flag to the Graphics class that says don't destroy me when the entity is removed.

Matt Tuttle

  • Administrator
  • Sr. Member
  • *****
  • Posts: 309
    • View Profile
    • Matt Tuttle's Blog
Re: HaxePunk 2.5.1
« Reply #2 on: February 26, 2014, 03:25:58 PM »
That's a valid question although perhaps I can explain it a bit better. FlashPunk originally allowed you to apply a Graphic object to multiple Entity objects so that when one of them is destroy the graphic doesn't disappear. This is why it works the way it does now.

In most cases you'll want to keep the image data in memory to prevent reloading from the image file. The Graphic object will be garbage collected automatically so you don't need to do anything special with it. If you find that you're running out of memory it would be better to destroy the AtlasData object instead. You can do that using the following code:

Code: [Select]
var data = AtlasData.getAtlasDataByName("graphics/large_background.png");
data.destroy();

mush

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: HaxePunk 2.5.1
« Reply #3 on: April 17, 2014, 03:45:25 PM »
For something like bullets, which I am going to be spawning by the hundreds or so, how should I handle something like this?



Im spawning them by clicking to test, however they dont always clear and stick to the screen until the last one is removed from the scene.
(my bullet code http://pastebin.com/aDr4Ak2N)

I shouldn't use the data.destroy method, should I? I don't really want to have to reload my bullet images so often.

Sorry if this is a dumb question, I'm not really understanding the purpose of the new graphic stuff w/ entities

ibilon

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 581
    • View Profile
    • My website
Re: HaxePunk 2.5.1
« Reply #4 on: April 18, 2014, 10:57:36 AM »
You could simply use an Entity, even if there are hundreds that should be fine,
unless on mobile maybe.

EDIT:
Just looked at your code, you already use an entity, so simply don't destroy the graphic, it'll stay in memory but that's ok since you'll probably use it very often.

mush

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: HaxePunk 2.5.1
« Reply #5 on: April 18, 2014, 06:11:26 PM »
It still happens, but not as frequent now. I appreciate your suggestion.
If this should be in a different thread I understand, but its a problem I would like to fix since its kind of annoying in-game to differentiate between actual moving bullets and ones left stuck to the screen from this issue