Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - thoniel

Pages: 1 [2]
16
DotNet / AccessViolationException when changing properties
« on: July 17, 2009, 01:36:44 am »
hi there,
ive got a silly problem.

im writing a textbox right now and ive encountered several errors with String2d.

when i change and read properties like Text several times before drawing (often initiated through events) i get the AccessViolationException.

Code: [Select]
System.AccessViolationException was unhandled
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=sfmlnet-graphics
  StackTrace:
       at SFML.Graphics.String2D.sfString_GetText(IntPtr This)
       at SFML.Graphics.String2D.get_Text()
  [...]


am i doing something wrong or is this a bug? how can i avoid this?

(the last days i avoided this by changing text just before drawing, but now i need to change it several times as i try to measure the width of the string)

this is the code:

Code: [Select]
       public int Width
        {
            get
            {
                string oldText = Text;
                if (oldText.Length == 0)
                    return 0;

                float start = drawable.GetCharacterPos(0).X;
                Text = oldText + "|";
                float end = drawable.GetCharacterPos((uint)oldText.Length).X;

                Text = oldText;
                return (int)(end - start);
            }
        }

17
Window / KeyEventArgs.Alt / Control / Shift
« on: July 14, 2009, 11:57:55 pm »
yeah thanks. the biggest reason to use this library is your support ;)

18
Window / KeyEventArgs.Alt / Control / Shift
« on: July 14, 2009, 10:04:16 pm »
so, is that a bug or am i getting the meaning of the booleans wrong?

19
Window / KeyEventArgs.Alt / Control / Shift
« on: July 14, 2009, 07:00:35 pm »
yeah sorry, they are unrelated in sfml but in my Input class i put your input functions and in addition the events from Window


Code: [Select]

            window.KeyPressed += new EventHandler<SFML.Window.KeyEventArgs>(OnKeyPressedSFML);

Code: [Select]


        private void OnKeyPressedSFML(object sender, SFML.Window.KeyEventArgs args)
        {
            String ret = "SFML:";

            if (args.Alt)
                ret += " Alt";

            if (args.Control)
                ret += " Ctrl";

            if (args.Shift)
                ret += " Shift";

            ret += " " + args.Code;

            write(ret);
        }

20
Window / KeyEventArgs.Alt / Control / Shift
« on: July 14, 2009, 04:54:41 pm »
hi
im using sfml 1.5 with c# and trying to wrap parts of sfml so have it easy to modifiy things.

right now, im wrapping Input in my own input class. and by that i recognized that KeyEventArgs.Alt etc. do not seem to work.

i have a method that listens to KeyPressed for example. but when i press Alt and A,first Alt and then A events are fired (in the keycodes, the booleans are never true).

is that right?

cheers

21
Graphics / does it makes sense to have a lot sprites of the same image?
« on: September 30, 2008, 08:49:22 pm »
hi
im trying to do a tilemap right now and i have a lot sprites of the same image to cover the floor.
im used to draw the same image over and over again on different positions.

does it make sense to have for each groundtile one sprite, or should i make one sprite and then draw it. change position, draw it again etc.

i guess visually it would come out the same but in termes of memory the first one may be inefficient.

what do you say?

cheers

Code: [Select]
void MapLayer::Draw(const sf::RenderWindow &window)
{
for(int y=0; y<5; y++) {
for(int x=0; x<4; x++) {
if (grid.at(y).at(x) == 0) {
pSprite->SetPosition(x*32,y*32);
window.Draw(*pSprite);
}
}
}
}

Pages: 1 [2]