Author Topic: Overhead to loadGraphic()?  (Read 1473 times)

Gilda

  • Active Member
  • ***
  • Posts: 123
  • Karma: +0/-0
    • View Profile
Overhead to loadGraphic()?
« on: Mon, Apr 1, 2013 »
My game has a large amount of animation and needs multiple sheets for the player depending on the weapon he's holding. So I must call loadGraphic() every time the player changes weapons to get the correct sheet, does doing this cause any excess memory to be used up that I could avoid using another method?

c023-DeV

  • Game Artisan
  • Active Member
  • ***
  • Posts: 176
  • Karma: +0/-0
    • View Profile
    • DeV-ZoO
Re: Overhead to loadGraphic()?
« Reply #1 on: Mon, Apr 1, 2013 »
hey, as far as I know loading stuff during runtime gives you some stuttering, well it's not too good.

I load all sprites needed at the beginning and turn them to visible = false; and flip that switch when they are needed...

or

Best would be to put them on to one sheet and handle it with animations...

hope it helps =)
If you aint got no dedication, you won't get no education!

war_fire

  • Guest
Re: Overhead to loadGraphic()?
« Reply #2 on: Mon, Apr 22, 2013 »
I think te easiest way would be to have a weapon grapgic plus body graphic.
Try a player class that extends FlxGroup, but has x/y, acceleration, velocity + other values, so when they are set you just set the value for both the player and the weapon.

IQAndreas

  • Member
  • **
  • Posts: 35
  • Karma: +0/-0
    • View Profile
    • IQAndreas.com
Re: Overhead to loadGraphic()?
« Reply #3 on: Tue, Apr 30, 2013 »
The first time you call "loadGraphic()" there is some overhead as Flixel creates and instance of the BitmapData and stores it, but after that initial call, any subsequent calls to "loadGraphic" accessing the same class are relatively quick, and won't noticeably affect how much memory is used at all.