Zdravim momentalne sa hram s GUI v C sharp a robil som pohyb objektov konkretne 2,jeden stvorec a druhy je button ,avsak rozdiel je ze pri stvorci sa mi to hybalo s KeyDown funkciou ale s buttonom s KeyUp funkcou
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace OBject_Moving
{
public partial class FormView : Form
{
public FormView()
{
InitializeComponent();
}
private void button1_KeyDown(object sender, KeyEventArgs e)
{
}
private void button1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Left)
{
this.button1.Left -= 10;
}
else if (e.KeyCode == Keys.Right)
{
this.button1.Left += 10;
}
else if (e.KeyCode == Keys.Up) {
this.button1.Top -= 10;
}
else if (e.KeyCode == Keys.Down)
{
this.button1.Top += 10;
}
}
A taky detail (pre istotu) to "e.KeyCode" v podstate nacita "to co si stlacil" ,laicky povedane? :-) Ďakujem pekne :)