Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Klicke der Maus zählen

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

schon mal vorab: ich bin neu hier, und programmiere noch nicht sehr lange. :D

Also zu meiner Frage:

ich möchte ein einfaches Spiel programmieren(3 gewinnt), und will dazu die Klicke der linken Maustaste in einem bestimmten bereich zählen, um zu ermitteln welcher Spieler am zug ist.

Mein X Wert ist in der Variabel m_x gespeichert, das gleich gilt auch für Y.

Hier mein Quellcode:

void Cgewinnt2Dlg::OnLButtonDown(UINT nFlags, CPoint point)

{

if((OnLButtonDown||m_x<325||m_y<273))

{

int i;

i++;

}

}

Was mache ich falsch?

Vielen Dank schon mal, für nützliche Beiträge!:)

Also wenn du jeden einzelnen Klick zählen willst, solltest du die i-Variable außerhalb des Events deklarieren, da sonst bei jedem Klick die Variable neu deklariert und wieder von 0 gezählt wird.

Ach ja, außerdem musst du sowieso i initialisieren, d.h. der Variable einen Wert zuweisen, bevor du inkrementieren kannst.


int i=0;

private void Click(object sender, EventArgs e)

{

      i++;

}

Bearbeitet von Mr. W

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.