Author Topic: Object reference not set to an instance of an object.  (Read 14821 times)

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Object reference not set to an instance of an object.
« Reply #15 on: 2007-03-12, 03:13:36 PM »
It says,
Cannot copy library:The destination folder is a subfolder of the source folder

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Object reference not set to an instance of an object.
« Reply #16 on: 2007-03-12, 05:21:15 PM »
You tried to copy too much.  Only copy the dll files, not the directory called "Library"
Edward Dassmesser

sam

  • Fanatic
  • ***
  • Posts: 303
  • This statement is false.
    • MSN Messenger - samlancashire@hotmail.com
    • View Profile
    • samlancashire.com
    • Email
Re: Object reference not set to an instance of an object.
« Reply #17 on: 2007-03-18, 02:00:14 PM »
I got the same error...Finally got it fixed by only copying the "d3dx9_30.dll" file from SHFL folder to my Tutorial Proj. folder.

sam

  • Fanatic
  • ***
  • Posts: 303
  • This statement is false.
    • MSN Messenger - samlancashire@hotmail.com
    • View Profile
    • samlancashire.com
    • Email
Re: Object reference not set to an instance of an object.
« Reply #18 on: 2007-03-18, 02:37:48 PM »
I managed to get through the tutorial finally (on my second attempt. No idea what I did wrong on first attempt).
My Tut Proj
I learned a lot...
Just one question -- How do I make the stars on the inventory map transparent?

----
EDIT: If Geocities doesn't let you download the file (It wouldn't let me) remove te "us.share" from the beginning of the url, so it's just "http://geocities.com/...". Not sure why that's not working...
« Last Edit: 2007-03-18, 02:41:23 PM by sam »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Object reference not set to an instance of an object.
« Reply #19 on: 2007-03-18, 03:08:58 PM »
If you want to make the stars on the inventory map transparent, create another tile mapping for tile index 4 in the tileset editor.  Delete the default triangle graphic from the tile and put just the star in without the blue background (like tile 2 had).  Then change the "Draw stars at top of screen" rule (this is in the "Draw Stars" plan in the "Inventory" layer).  Change the "2" (which references the star with the opaque background) to a "4" (which you just created without a background).

How much of the whole process did you understand?  Did it actually make sense or did you just follow the steps and accept it all as magic? :)  Is there anything you'd like to understand more about that you think could use some more comments in the tutorial?

sam

  • Fanatic
  • ***
  • Posts: 303
  • This statement is false.
    • MSN Messenger - samlancashire@hotmail.com
    • View Profile
    • samlancashire.com
    • Email
Re: Object reference not set to an instance of an object.
« Reply #20 on: 2007-03-18, 05:31:12 PM »
Thanks.
Surprisingly I understood most of it all. The only thing I wasn't too sure about was the formulas in this:
Quote
Add another new rule named "Turn left"
Select "Do" from the first dropdown and "SwitchToState" from the second dropdown.
Type "(state + 1) % 72" in the "State" combo box.  This is the formula for calculating the next state number for turning left in a 72-state sprite.  Normally you could simply import a rotating sprite instead of having to know formulas, but this tutorial will show you all the details.
Select "RelativePosition.TopLeft" from the "Alignment" dropdown list.  This selection is really irrelavent because all states are the same size, so it's not important what you pick.
Check the "End If/End While" checkbox to end the first rule's condition.
Add a new rule named "If player is pressing right"
Select "If" from the first dropdown and "IsInputPressed" from the next dropdown.
Select "SpriteBase.InputBits.Right" from the "Input" dropdown list.
Select "false" from the "InitialOnly" dropdown list.
Add a new rule named "Turn right"
Select "Do" from the first dropdown and "SwitchToState" from the second dropdown.
Type "(72 + state - 1) % 72" in the "State" combo box.  This is the formula for calculating the next state for turning right.
Select "RelativePosition.TopLeft" from the "Alignment" dropdown list.
Check the "End If/End While" checkbox to end the "If player is pressing right" condition.
I don't understand how they work...

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Object reference not set to an instance of an object.
« Reply #21 on: 2007-03-18, 06:16:14 PM »
(state + 1)

This takes the number representing the current state, and adds 1 to it, since the number representing the state 5 degrees to the left is one greater than the current state, based on how the states were created.

Of course, if the number representing the current state is already at the max value of 71 (72 states, starting at 0), then you don't want it to keep increasing, you want it to move back over to 0.  So you use:

(state + 1) % 72

% is the modulus operator, which basically takes the remainder of the first argument divided by the second.  In essence, it makes sure the number stays less than the second operator.  For example:

5 % 72 = Remainder of 5/72.  Since 5/72 = 0r5, 5 % 72 == 5, so it has no effect for most cases.

Now, imagine state == 71.

(71 + 1) % 72 == 72 % 72 == Remainder of 72/72.  Since 72/72 = 1, and there is no remainder, then (71+1)%72 == 0.

The other direction is a bit trickier.

(72 + state - 1) % 72

This could be simplified as

(state - 1)

If only it would automatically wrap around when state == -1, but it doesn't.  So when it gets to -1, we have to reset it to 71.  There are two ways to do this: With an If statement, but this takes an extra command, or with modulo arithmetic:

Always adding 72 to a number before taking that number mod 72 is the same as doing nothing before taking that number mod 72.  Since 5/72 == 0r5, and (72 + 5)/72 == 77/72 == 1r5, we can see that the remainder is the same.  So by adding 72, we don't change the result in any case... except when state is 0:

(72 + state - 1) % 72 == (72 + 0 - 1) % 72 == 71 % 72 == 71.

The reason we have to add 72 first, is because -1 % 72 == -1.  Not useful.

So it automatically wraps back around when trying to turn to the right when you're already at state 0, and it automatically wraps back around when trying to turn to the left when you're already at state 71.
« Last Edit: 2007-03-18, 06:19:26 PM by durnurd »
Edward Dassmesser

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Object reference not set to an instance of an object.
« Reply #22 on: 2007-03-18, 11:15:50 PM »
I now get,
Test Project\Project.cs(53,14) : error CS0131: The left-hand side of an assignment must be a variable, property or indexer
Test Project\Project.cs(53,14) : error CS0029: Cannot implicitly convert type 'string' to 'bool'
It's the same as one of the errors I was having earlier.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Object reference not set to an instance of an object.
« Reply #23 on: 2007-03-19, 06:03:35 AM »
I managed to get through the tutorial finally (on my second attempt. No idea what I did wrong on first attempt).
My Tut Proj
I learned a lot...
Just one question -- How do I make the stars on the inventory map transparent?

----
EDIT: If Geocities doesn't let you download the file (It wouldn't let me) remove te "us.share" from the beginning of the url, so it's just "http://geocities.com/...". Not sure why that's not working...

FYI:
1) Geocities just doesn't like direct links to its files.  If you manually type the URL in the address bar it will download fine.
2) Unlike version 1.x, with SGDK2, you only need to distribute the .SGDK2 file to others that have SGDK2.  It contains all the game's code and data.  If you want to distribute your game to someone who doesn't have SGDK2, select "Delete Intermediate Files" from the file menu, then distribute everything left in the project folder (and not the .SGDK2 file).

Now... I'm looking at your tutorial project to see if it looks like mine.  I noticed that your star and triangle aren't using fancy gradient fills as described in the tutorial.  Why not?  I also notice they're pointing the wrong direction.  The triangle should be pointing straight up and the stars top point should be straight up (although that doesn't *really* matter).  I also noticed that you put the triangle before the star when it should have come after.  (Due to the way anti-aliased rotation works, the cell needs to not be next to any graphics that fill their cell because it will pick up pixels from them and I don't know how to prevent it.)

Do you know what could have happened to your project since it was last working that would have caused it to start having that error?  Are your overlay map and startup map settings still valid?  Maybe you can re-zip your project (just the SGDK2 file this time) and post it where the old one was and I can take look.

EDIT: attached is my version of the tutorial... ehmm... you can ignore the car, which I imported to remind me of my rotation formulas and then neglected to finish deleting.

EDIT 2: Try resetting the source code and re-applying the fixes to project.cs.  The error appears to be on line 53 of that file.  Or just check that line to see if anything looks obviously wrong.
« Last Edit: 2007-03-19, 06:14:10 AM by bluemonkmn »

sam

  • Fanatic
  • ***
  • Posts: 303
  • This statement is false.
    • MSN Messenger - samlancashire@hotmail.com
    • View Profile
    • samlancashire.com
    • Email
Re: Object reference not set to an instance of an object.
« Reply #24 on: 2007-03-19, 04:04:21 PM »
Oo thanks...Curse you Geocities!!
I didn't pay too much attention to following graphics instructions because I had already done half the tutorial once and knew what was needed for the tut. So i just did them quickly, not realizing that there needed to be no tiles next to the tile being rotated. Also, as for the gradient fills I remember the first time I did the tutorial I couldn'nt get that right either so I just didn't bother this time.

EDIT: Downloaded your tutorial. It seems every time I make a project / download I always need to copy d3dx9_30.dll into the project files folder to get the game to run...
« Last Edit: 2007-03-19, 04:09:14 PM by sam »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Object reference not set to an instance of an object.
« Reply #25 on: 2007-03-19, 06:18:16 PM »
1) What's happening when you try a gradient fill?  What exactly are you doing to try to make it work?

2) Until I release the next alpha, it will be necessary to manually copy d3dx9_30.dll into the generated project folder each time the contents of a project folder are cleared or created, unless your system has the same version of DirectX installed that SGDK2 uses, or later.  (Or you could just copy d3dx9_30.dll into your system32 folder yourself.)

sam

  • Fanatic
  • ***
  • Posts: 303
  • This statement is false.
    • MSN Messenger - samlancashire@hotmail.com
    • View Profile
    • samlancashire.com
    • Email
Re: Object reference not set to an instance of an object.
« Reply #26 on: 2007-03-19, 08:13:28 PM »
1) Sorry don't remember I just didn't understand something and I haven't tried it again yet. I'll post when I do.
2) Ah heck, I'll just paste it into my system32 folder, thanks.

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Object reference not set to an instance of an object.
« Reply #27 on: 2007-03-28, 01:08:14 AM »
Just installed alpha 3!  ;D New error now,

Code: [Select]
Test Project\Lev_1_Map.cs(180,14) : error CS1501: No overload for method 'ByteLayer' takes '13' arguments
Test Project\Lev_1_Map.cs(211,14) : error CS1501: No overload for method 'ByteLayer' takes '13' arguments
Test Project\Lev_1_Map.cs(242,14) : error CS1501: No overload for method 'ByteLayer' takes '13' arguments
Test Project\Lev_1_Map.cs(273,14) : error CS1501: No overload for method 'ByteLayer' takes '13' arguments
Test Project\Lev_1_Map.cs(306,14) : error CS1501: No overload for method 'ByteLayer' takes '13' arguments
Test Project\Lev_1_Map.cs(373,14) : error CS1501: No overload for method 'ByteLayer' takes '13' arguments
Test Project\Project.cs(53,14) : error CS0131: The left-hand side of an assignment must be a variable, property or indexer
Test Project\Project.cs(53,14) : error CS0029: Cannot implicitly convert type 'string' to 'bool'

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Object reference not set to an instance of an object.
« Reply #28 on: 2007-03-28, 05:01:04 AM »
New SGDK2 Release + Errors on old project => Reset the source code.

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Object reference not set to an instance of an object.
« Reply #29 on: 2007-03-28, 11:52:53 PM »
Thanks!  ;D   Finally got it working!  :) Hopefully I'll remember that for next time!  ;)  Now I'm going to do the tutorial!   8)