Jump to content


Photo

Saving The Humans - Animateenemy() Problem


  • Please log in to reply
3 replies to this topic

#1 Ultigma

Ultigma

    New Member

  • Members
  • Pip
  • 1 posts

Posted 11 March 2014 - 10:53 AM

Problem Solved
Turns out it was my playArea's width and height was 0 so no play area actually exsisted...
SILLY ME!

How I figured it out was to check the stack trace. I did this by looking t at he "Locals" tab in the bottom window, and opening each property that had "+base" till there was no more and clicked the magnifying glass on the error and viewed the stack trace.

Perhaps this might help someone else figure out their problem?

Cheers
------------------------------------------------------------------------------------------------

Hello, literally just signed up hoping to find an answer =)

I have been following the code as stated and have hit a problem I'm not to sure about. I tried to work it out but with my limited knowledge, not sure what I'm doing.

When I click the start Button I hit an error:

" An exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll but was not handled in user code

Additional information: 'maxValue' must be greater than zero. ".

and it highlights this part of the code.

AnimateEnemy(enemy, [b]random.Next((int)playArea.ActualHeight - 100),
                random.Next((int)playArea.ActualHeight - 100)[/b], "(Canvas.Top)");

Not sure what this is referring to, pretty sure everything is as typed in the book.

Thanks for any help
Update!

After scanning the code, I found out it was something to do with the random.Next((int)playArea.ActualHeight - 100),
random.Next((int)playArea.ActualHeight - 100)


Is there something wrong with the way it is formatted? According to the IDE it's returning 0.

Edited by Ultigma, 11 March 2014 - 12:36 PM.


#2 wunderwaffe

wunderwaffe

    Active Member

  • Members
  • PipPip
  • 26 posts

Posted 12 March 2014 - 01:52 AM

Problem Solved
Turns out it was my playArea's width and height was 0 so no play area actually exsisted...
SILLY ME!

How I figured it out was to check the stack trace. I did this by looking t at he "Locals" tab in the bottom window, and opening each property that had "+base" till there was no more and clicked the magnifying glass on the error and viewed the stack trace.

Perhaps this might help someone else figure out their problem?

Cheers
------------------------------------------------------------------------------------------------

Hello, literally just signed up hoping to find an answer =)

I have been following the code as stated and have hit a problem I'm not to sure about. I tried to work it out but with my limited knowledge, not sure what I'm doing.

When I click the start Button I hit an error:

" An exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll but was not handled in user code

Additional information: 'maxValue' must be greater than zero. ".

and it highlights this part of the code.

AnimateEnemy(enemy, [b]random.Next((int)playArea.ActualHeight - 100),
                random.Next((int)playArea.ActualHeight - 100)[/b], "(Canvas.Top)");

Not sure what this is referring to, pretty sure everything is as typed in the book.

Thanks for any help
Update!

After scanning the code, I found out it was something to do with the random.Next((int)playArea.ActualHeight - 100),
random.Next((int)playArea.ActualHeight - 100)


Is there something wrong with the way it is formatted? According to the IDE it's returning 0.


Indeed, I'm average at coding but I'm pretty competent at debugging.

One of the things Andrew deserves credit for (at least in the 2nd ed.) is introducing Debugging in Chapter 2.

Sharing ideas that help people help themselves is always good.

:)

#3 AndrewStellman

AndrewStellman

    Andrew Stellman

  • O'Reilly Author
  • PipPipPipPipPipPipPipPipPipPipPip
  • 832 posts
  • Gender:Male
  • Location:Brooklyn, NY
  • Interests:Author of: "Head First C#", "Beautiful Teams", "Head First PMP", "Applied Software Project Management"

Posted 12 March 2014 - 11:47 AM

Thanks! That was an improvement I made with the second edition -- the first edition pushed it back to later in the book, and it was one of the first things I corrected the second time around.
Andrew Stellman
Author, Head First C#
Building Better Software -- http://www.stellman-greene.com

#4 stjepo

stjepo

    New Member

  • Members
  • Pip
  • 1 posts

Posted 29 April 2015 - 12:58 AM

I had this error even I had followed the book instructions (I started 3 times).

 

In the book, page 24 3Âședition, is recommended that  the Width and Height gameplay area  should be set to AUTO. 

 

If it is done Always  you get AUTO (0), the only way to avoid this error is to put fix dimension.

 

I did it and it worked. I seems that  Width and Height AUTO is not working in Visual Express 2013.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users