• 大小: 2.33MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-10
  • 语言: Java
  • 标签:

资源简介

一个java版的连连看,基本实现了连连看的玩法,着重游戏的UI美观。目前关卡还比较简单。

资源截图

代码片段和文件信息

package com.yunzhi.lianliankan;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.Jframe;
import javax.swing.JLabel;
import javax.swing.JPanel;
class Game implements ActionListener 

Jframe mainframe; 
int SCRW;
int SCRH;
int COLS=10;
int ROWS=5;
JLabel label;
Dimension screen;
JPanel mainpanelcenterPanelsouthPanelnorthPanel;
ImageIcon img;
JButton aniButton[][] = new JButton[COLS][ROWS];
JButton exitButtonrandButtonnewlyButton; 
JLabel score=new JLabel(“0“); 
JLabel fraction;
JButton firstButtonsecondButton;
int grid[][] = new int[COLS+2][ROWS+2];
static boolean pressInformation=false; 
int x0=0y0=0x=0y=0fristMsg=0secondMsg=0validateLV; 
int ijkn;
int imgwimgh;
public void init(){
screen=Toolkit.getDefaultToolkit().getScreenSize();
img=new ImageIcon(“src/youxi.png“);
SCRH=img.getIconHeight();
SCRW=img.getIconWidth();
mainframe=new Jframe(“连连看“); 
mainframe.setBounds(screen.width/2-SCRW/2screen.height/2-SCRH/2SCRWSCRH);
label=new JLabel(img);
label.setBounds(00SCRWSCRH);
mainframe.getlayeredPane().add(labelnew Integer(Integer.MIN_VALUE));
img=new ImageIcon(“src/1.png“);
imgw=img.getIconWidth()+2;
imgh=img.getIconHeight()+2;
mainpanel=new JPanel();
mainframe.setContentPane(mainpanel);
mainpanel.setLayout(new BorderLayout());
mainpanel.setOpaque(false);
centerPanel=new JPanel(); 
southPanel=new JPanel(); 
northPanel=new JPanel();
centerPanel.setOpaque(false);
southPanel.setOpaque(false);
northPanel.setOpaque(false);
mainpanel.add(centerPanel“Center“); 
mainpanel.add(southPanel“South“); 
mainpanel.add(northPanel“North“); 
centerPanel.setLayout(null); 
for(int cols = 0;cols < COLS;cols++){ 
for(int rows = 0;rows < ROWS;rows++ ){
img=new ImageIcon(“src/“+String.valueOf(grid[cols+1][rows+1])+“.png“);
aniButton[cols][rows]=new JButton(img);
aniButton[cols][rows].setLayout(null);
aniButton[cols][rows].setBounds(SCRW/2-COLS*imgw/2+cols*imgwrows*imghimg.getIconWidth()img.getIconHeight());
aniButton[cols][rows].setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
aniButton[cols][rows].setBorder(null);
aniButton[cols][rows].setContentAreaFilled(false);
aniButton[cols][rows].setMargin(null);
aniButton[cols][rows].addActionListener(this); 
centerPanel.add(aniButton[cols][rows]); 


exitButton=new JButton(“返回“); 
exitButton.setContentAreaFilled(false);
exitButton.setBorder(null);
exitButton.addActionListener(this);
img=new ImageIcon(“src/shuaxin.png“);
randButton=new JButton(“随机“);
randButton.setContentAreaFilled(false);
randButton.setBorder(null);
randButton.addActionListener(this); 
newlyButton=new JButton(“刷新“);
newlyButton.setContentAreaFilled(false);
newlyButton.setBorder(null);
newlyButton.addActi

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件         232  2017-12-25 10:19  lianliankan\.classpath
     文件         387  2017-12-25 10:03  lianliankan\.project
     文件          92  2017-12-25 10:29  lianliankan\.settings\org.eclipse.core.resources.prefs
     文件         603  2017-12-25 10:03  lianliankan\.settings\org.eclipse.jdt.core.prefs
     文件        9783  2017-12-26 12:56  lianliankan\bin\1.png
     文件       10746  2017-12-26 12:56  lianliankan\bin\2.png
     文件       10228  2017-12-26 12:56  lianliankan\bin\3.png
     文件       10087  2017-12-26 12:56  lianliankan\bin\4.png
     文件       10268  2017-12-26 12:56  lianliankan\bin\5.png
     文件        9473  2017-12-26 12:56  lianliankan\bin\6.png
     文件        9734  2017-12-26 12:56  lianliankan\bin\7.png
     文件       10825  2017-12-26 12:56  lianliankan\bin\8.png
     文件        9537  2017-12-26 12:56  lianliankan\bin\9.png
     文件        8737  2017-12-30 16:26  lianliankan\bin\com\yunzhi\lianliankan\Game.class
     文件        5383  2017-12-30 16:26  lianliankan\bin\com\yunzhi\lianliankan\Lianliankan.class
     文件        6280  2017-12-26 12:56  lianliankan\bin\dengji.png
     文件        6283  2017-12-26 12:56  lianliankan\bin\fenshu.png
     文件      355567  2017-12-25 14:15  lianliankan\bin\icon.png
     文件      464554  2017-12-26 12:56  lianliankan\bin\menu.png
     文件       22742  2017-12-26 15:29  lianliankan\bin\more.png
     文件       11000  2017-12-26 12:56  lianliankan\bin\shuaxin.png
     文件       24494  2017-12-26 15:29  lianliankan\bin\start.png
     文件      233225  2017-12-26 23:28  lianliankan\bin\youxi.png
     文件        9783  2017-12-26 12:56  lianliankan\src\1.png
     文件       10746  2017-12-26 12:56  lianliankan\src\2.png
     文件       10228  2017-12-26 12:56  lianliankan\src\3.png
     文件       10087  2017-12-26 12:56  lianliankan\src\4.png
     文件       10268  2017-12-26 12:56  lianliankan\src\5.png
     文件        9473  2017-12-26 12:56  lianliankan\src\6.png
     文件        9734  2017-12-26 12:56  lianliankan\src\7.png
     文件       10825  2017-12-26 12:56  lianliankan\src\8.png
............此处省略11个文件信息

评论

共有 条评论

相关资源