Author Topic: ImageAdd seems to be crashing?  (Read 2811 times)

Pugmartin

  • Guest
ImageAdd seems to be crashing?
« on: May 13, 2012, 11:25:04 am »
Hi All,

Right then, managed to get loads of stuff working within DragonFire this past week but hit a brick wall for a bit and for all I have a workaround, I'd like to know if anyone else has the same problem?

I have quite a big lump of a basic bare bones game working, and have for a some time now. All has been working well.
However, I wanted to start jazzing it up a little and having various frames of animation for varying states for views rather than the static stuff I started out with.

I had a load of new stuff added that was working fine in the simulator, hence I was unaware of any problem. Once built and installed on the iPhone however I hit a snag - the app would simply show the logo loading screen and then quit back to the Home screen.

This has taken me ages to pinpoint, though i can now say that all works fine until I simply enable one line in my code:

The ImageAdd() command appears to be the culprit. If I simply change and use ViewAdd() instead (passing the exact same image file to use), then all is well on the iPhone build.
Any ideas why?
While I can work around in the short term, I would much prefer to have an array of Images loaded that I can swap using ViewSetImage().

Thanks in advance, great forum - though where have all the old guys gone that used to frequent the old forum?

rjanes

  • Guest
Re: ImageAdd seems to be crashing?
« Reply #1 on: May 13, 2012, 06:10:52 pm »
It's hard to say without seeing the line of code causing the issue, but are you only calling your ImageAdds in your AppMain(), or a function called within AppMain().  Calling image add  anywhere else is likely to cause a memory leak and or other various issues.  You basically want to use ImageAdd at the start of the application to load the image, then use ViewSetImage() to change the views image later on within your application.  You can also use ImageSetImage() to redefine an images PNG.

expleo

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: ImageAdd seems to be crashing?
« Reply #2 on: May 14, 2012, 12:25:54 am »
My best bet too, I guess you use imageadd 'runtime' Make sure you initiate and load all resource files in a seperate function, and call it once at start of app (in main)

Pugmartin

  • Guest
Re: ImageAdd seems to be crashing?
« Reply #3 on: May 14, 2012, 01:03:16 am »
Hi guys,

Thanks for the replies. Unfortunately I can report that I am indeed attempting to call ImageAdd() only in AppMain() itself and nowhere else.

expleo

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
    • View Profile
Re: ImageAdd seems to be crashing?
« Reply #4 on: May 14, 2012, 01:24:17 am »
Ok, I look again, and this is what I find weird. You say that it works with a viewadd. The viewadd is to present an image laoded with the imageadd.

So it is something like this:

int myImageHandler;
int myViewHandler;

myImageHandler = ImageAdd("myimage.png");
myViewHandler = ViewAdd(myImageHandler ,X,Y);

Perhaps it is easier if you copy your code (or at least, just the image part)
« Last Edit: May 14, 2012, 01:30:16 am by expleo »

Pugmartin

  • Guest
Re: ImageAdd seems to be crashing?
« Reply #5 on: May 14, 2012, 03:22:20 am »
Hi there,

Please see below...

WORKING CODE:

**(defined as global at top of code)
**int vwBlueBar;
**int vwRedBar;

void AppMain()
{
   vwBlueBar=ViewAdd("Images/BlueBar.png",16,448);
   vwRedBar=ViewAdd("Images/RedBar.png",16,448);
   ViewSetVisible(vwRedBar,1);
   ViewSetVisible(vwBlueBar,0);

**Other stuff setup here...

}



WONT WORK:

**(defined as global at top of code)
**int imgBlueBar;
**int imgRedBar;
**int vwBar;


void AppMain()
{
   imgBlueBar=ImageAdd("Images/BlueBar.png");
   imgRedBar=ImageAdd("Images/RedBar.png");
   vwBar=ViewAdd(imgRedBar,16,448);
**Other stuff setup here...

}




   

tim

  • Administrator
  • Hero Member
  • *****
  • Posts: 1595
  • Karma: +11/-1
    • View Profile
    • DragonFireSDK
Re: ImageAdd seems to be crashing?
« Reply #6 on: May 14, 2012, 07:54:33 am »
Pugmartin,

Either of those should work.  Can you please send me the code in question so I can take a look?

Thanks.
Tim Sommers
DragonFireSDK Team

Pugmartin

  • Guest
Re: ImageAdd seems to be crashing?
« Reply #7 on: May 15, 2012, 03:57:54 am »
Tim,

PM Sent - thanks for the support.