Form related crash issue

Questions regarding syntax

Form related crash issue

Postby 13corstena » Fri Jan 13, 2012 5:23 am

Hello, I am working on a game and I seem to be getting an error with when the program reaches a certain number of forms opened. I am making a side scrolling game, and as the character enters the end of one screen, it will exit that form, and as the other form opens, it will close the previous one. The issue I am getting with it is after 4 forms of closing/opening (specifically when the fourth form is opened) I get a nullpointer exception error and the program crashes. I have tried creating an app seeing if it was only an error in kbasic and it still crashes.

In terms of errors in coding, I have changed what form the start game starts on and it still crashes after 4 forms have been opened/close.

Example: When the start button is clicked on form1, the game will start on forest1, continue into forest 2, and crash when forest 3 opens (the 4th form to open). When I then change it so when the start button on form1 is clicked and open forest2 instead of 1, forest 3 will work fine, but then crash when forest 4 open (once again, the 4th form to open).

Here is some example code of when a form opens (on forest1):
Code: Select all
Private Sub Form_OnOpen
  form1.close
End Sub


And when the form closes (on forest1):
Code: Select all
Private Sub tmrportal_OnEvent()
  If imgheroup.x > 530 then
  forest2.opencentered
  End If
End Sub

Maybe something is wrong with the code and if that is the case, I will feel silly, or maybe there is just a more effective manner in changing forms, or maybe even a bug. If any can I have some help with this issue? If you would like a copy of the program (as it is too big to upload on the forum) send me your email and I will send the full copy over.

Thanks in advance
13corstena
 
Posts: 1
Joined: Fri Jan 13, 2012 4:46 am

Re: Form related crash issue

Postby Henning » Fri Jan 13, 2012 7:17 pm

Hi,

I just made a small project with 5 Forms with 2 Buttons, Prev/Next.

Moving forward/backwards works, as long as not to Form1 again???????

/Henning

ManyForms.kbasic_project.zip
(2.53 KiB) Downloaded 134 times
Henning
 
Posts: 262
Joined: Mon Feb 09, 2009 12:03 am
Location: Sweden

Re: Form related crash issue

Postby Henning » Tue Jan 17, 2012 12:13 am

Me again,

Would be interesting if someone could test, by changing the [Next] button event on the last Form to open Form1. Here that crashes the program.

/Henning
Henning
 
Posts: 262
Joined: Mon Feb 09, 2009 12:03 am
Location: Sweden

Re: Form related crash issue

Postby Slowdown » Tue Jan 24, 2012 8:02 pm

@Henning,

Got it to work correctly :D
Change the properties of Form1 OpenOnRun from False to True.

missed this topic.
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands

Re: Form related crash issue

Postby Slowdown » Wed Jan 25, 2012 8:11 am

This is the fxx limit, i'm signing off.
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands


Return to Coding Questions

cron