【急】如何用VB制作拼图游戏
要求:1、将一张图片分成六等份,出现在窗体下方2、右边有一个带有分隔线的方框3、将下方的图片拖入方框中拼合完成初始样子...
要求:1、将一张图片分成六等份,出现在窗体下方
2、右边有一个带有分隔线的方框
3、将下方的图片拖入方框中拼合完成
初始样子 展开
2、右边有一个带有分隔线的方框
3、将下方的图片拖入方框中拼合完成
初始样子 展开
展开全部
Dim a(0 To 5) As Integer
Private Sub crearnd() '随机分配分割后的图片
Randomize '注意这里放在循环是不同的,可是注意这里有时候图片放不满
For i = 0 To 5
a(i) = Int(Rnd * 6)
If i >= 2 Then
For j = 0 To i - 1
If a(j) = a(i) Then
i = i - 1 '注意这里可以控制i的值,也就是说可以控制For i = 0 To 5里i的值
End If
Next
End If
Next
End Sub
Private Sub Form_Load() '为什么把Picture2(i).Width 改为Picture2(i).scaleWidth不行?
For i = 0 To 5
Picture2(i).Width = Picture1.Width / 3
Picture2(i).Height = Picture1.Height / 2
Next i
End Sub
Private Sub spi_CLICK() 'imagebox没有paintpicture方法
crearnd
Picture2(a(0)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(1)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(2)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 2 * Picture1.ScaleWidth / 3, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(3)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 0, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(4)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(5)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 2 * Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(0).Move Picture1.Width, 0
Picture2(1).Left = Picture1.Width + Picture2(0).Width: Picture2(1).Top = 0
Picture2(2).Left = Picture1.Width + Picture2(0).Width + Picture2(1).Width: Picture2(2).Top = 0
Picture2(3).Left = Picture1.Width: Picture2(3).Top = Picture2(0).Height
Picture2(4).Left = Picture1.Width + Picture2(3).Width: Picture2(4).Top = Picture2(1).Height
Picture2(5).Left = Picture1.Width + Picture2(3).Width + Picture2(4).Width: Picture2(5).Top = Picture2(2).Height
End Sub
Private Sub Picture2_DragDrop(index As Integer, Source As Control, X As Single, Y As Single) '注意这里用Picture2(index)_DragDrop是错误的,这里可以自动识别index,比如在窗体加一个text,则会显示对象的值
Dim PIC As StdPicture
Set PIC = Source.Image
Set Source.Picture = Picture2(index).Image
Set Picture2(index).Picture = PIC '为什么把picture换为image就不行
End Sub
要工程文件的话给个邮箱
Private Sub crearnd() '随机分配分割后的图片
Randomize '注意这里放在循环是不同的,可是注意这里有时候图片放不满
For i = 0 To 5
a(i) = Int(Rnd * 6)
If i >= 2 Then
For j = 0 To i - 1
If a(j) = a(i) Then
i = i - 1 '注意这里可以控制i的值,也就是说可以控制For i = 0 To 5里i的值
End If
Next
End If
Next
End Sub
Private Sub Form_Load() '为什么把Picture2(i).Width 改为Picture2(i).scaleWidth不行?
For i = 0 To 5
Picture2(i).Width = Picture1.Width / 3
Picture2(i).Height = Picture1.Height / 2
Next i
End Sub
Private Sub spi_CLICK() 'imagebox没有paintpicture方法
crearnd
Picture2(a(0)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(1)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(2)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 2 * Picture1.ScaleWidth / 3, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(3)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 0, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(4)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(a(5)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 2 * Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
Picture2(0).Move Picture1.Width, 0
Picture2(1).Left = Picture1.Width + Picture2(0).Width: Picture2(1).Top = 0
Picture2(2).Left = Picture1.Width + Picture2(0).Width + Picture2(1).Width: Picture2(2).Top = 0
Picture2(3).Left = Picture1.Width: Picture2(3).Top = Picture2(0).Height
Picture2(4).Left = Picture1.Width + Picture2(3).Width: Picture2(4).Top = Picture2(1).Height
Picture2(5).Left = Picture1.Width + Picture2(3).Width + Picture2(4).Width: Picture2(5).Top = Picture2(2).Height
End Sub
Private Sub Picture2_DragDrop(index As Integer, Source As Control, X As Single, Y As Single) '注意这里用Picture2(index)_DragDrop是错误的,这里可以自动识别index,比如在窗体加一个text,则会显示对象的值
Dim PIC As StdPicture
Set PIC = Source.Image
Set Source.Picture = Picture2(index).Image
Set Picture2(index).Picture = PIC '为什么把picture换为image就不行
End Sub
要工程文件的话给个邮箱
追问
495595997@qq.com
谢谢~
追答
已经发送
展开全部
Picture2(a(0)).PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2, 0, 0, Picture1.ScaleWidth / 3, Picture1.ScaleHeight / 2
也就是这个命令的活用而已!(上面代码引用楼上的,这个命令长,不翻书,真还一下打不出来,呵呵)
也就是这个命令的活用而已!(上面代码引用楼上的,这个命令长,不翻书,真还一下打不出来,呵呵)
更多追问追答
追问
请问你能帮忙制作一下工程文件么?最好能和我发的那个图一样,如果一样的话可以再追加积分
追答
人家辛苦打那么多程序,咱就不抢人家生意了!呵呵,你找他要好了!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询