Autor Beitrag
niggo233
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46
Erhaltene Danke: 1

Win7
C#,NXT,PHP,Html,CSS,JavaScript
BeitragVerfasst: So 06.02.11 15:18 
Hi
ich möchte,dass ein Feind sich automatisch,nach oben,unten etc, bewegt,ohne dass ich eine Taste drücke,da ich eine andere Figur bewege.
Ich weiß aber nich wie das geht,kann mir jemand helfen?
mfg
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: So 06.02.11 15:25 
Das Stichwort dafür lautet: Timer

Mittels der Eigenschaft "Interval" setzt du die Zeit (in Millisekunden, d.h. z.B. 1000 für eine Sekunde) und im Timer.Tick-Ereignis bewegst du dann entsprechend die Figur (und rufst danach dann ein Neuzeichnen (Invalidate) auf - sofern du die Figuren selber zeichnest).
niggo233 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46
Erhaltene Danke: 1

Win7
C#,NXT,PHP,Html,CSS,JavaScript
BeitragVerfasst: So 06.02.11 16:19 
Ok
aber wie macht man des,sorry bin neu
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
Mein Code:
while (punkte == 20)
                {
                    feindX -= feindSpeed;
                    feindX += feindSpeed;
                    feindY -= feindSpeed;
                    feindY += feindSpeed;
                }
huuuuuh
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: So 06.02.11 16:51 
ausblenden C#-Quelltext
1:
2:
feindX -= feindSpeed;
feindX += feindSpeed;

was soll das machen?
so macht es jedenfalls nix... du ziehst von feindX etwas ab und addierst das selbe direkt wieder hinzu...
(für feindY gilt das selbe ;))
niggo233 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46
Erhaltene Danke: 1

Win7
C#,NXT,PHP,Html,CSS,JavaScript
BeitragVerfasst: So 06.02.11 16:58 
Hi
ja der code geht auch nicht hab gedacht des geht so.Hab ihn wo her kopiert
niggo233 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46
Erhaltene Danke: 1

Win7
C#,NXT,PHP,Html,CSS,JavaScript
BeitragVerfasst: Mo 07.02.11 18:31 
Aber wie geht denn dann dea mit den Timer?Wie lautet der Code
Mfg