0

我是 cocos2d 的新手。

我正在开发一款游戏。

而且我想对图层的点击事件进行一些记录。

我不知道当我们单击图层的某些精灵时会调用哪个方法。

我得到了控制,ccTouchesBegan(MotionEvent event)但我无法找到点击了哪个精灵。

这是代码:

CCSprite bridge = RetrivingImagesFromSDcard.getImage(Constants.scrooll_Sprites[tileDetailsList
                                                                                                           .get(tileID).tileSpriteID3]);
                            addChild(
                                    bridge,
                                    tileDetailsList.get(tileID).tileSpriteID3Zorder,tileDetailsList.get(tileID).tileSpriteID3Tag);
                            bridge.setPosition(tilesBG.getPosition().x,tilesBG.getPosition().y);
                            bridge.setRotation(tileDetailsList.get(tileID).tileAngle);
                            bridge_Sprite_ArrayList.add(bridge);

这是触摸事件

@Override
    public boolean ccTouchesBegan(MotionEvent event) {
        if (flagTap == false)
        {
            tapCount = tapCount+1;
            tapCountStr = Integer.toString(tapCount);
            Log.e("TapCount", "@@@@@@@@@@@@@@@@@"+tapCountStr);

            map.put(GameLayer.timVal,tapCountStr);
            System.out.println(map);
            //CHANGES DONE 8 FEB

            try
            { 

                GameLog gameLogObj = new GameLog();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
                String currentDateandTime = sdf.format(new Date());
                GameLayer.logLevelArgument = "INFO";
                GameLayer.logMsgArgument = "TAPBEFORELAUNCH";
                GameLayer.roundStr = Integer.toString(Constants.level);
                TrainMapLayer.flagLogType = true;  
                String MAPSIZE = ""+Constants.numberOfColumns+"x"+Constants.numberOfRows;

                gameLogObj.OpenAndAppendData(currentDateandTime, "UserId value", "sessionID Value",
                        " gameID Value", GameLayer.roundStr, "RoundDiscriptor", GameLayer.logMsgArgument,GameLayer.logLevelArgument,TrainMapLayer.flagLogType,MAPSIZE,"");


            }



            catch (Exception e) {
                Log.e("Exception in TAPBEFORELAUNCH",">>>>>>>>>>>>"+e);
                GameLog gameLogObj = new GameLog();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
                String currentDateandTime = sdf.format(new Date());
                GameLayer.logLevelArgument = "ERROR";
                GameLayer.logMsgArgument = e.toString();
                GameLayer.roundStr = Integer.toString(Constants.level);
                TrainMapLayer.flagLogType = false; 
                String MAPSIZE = ""+Constants.numberOfColumns+"x"+Constants.numberOfRows;

                gameLogObj.OpenAndAppendData(currentDateandTime, "UserId value", "sessionID Value",
                        " gameID Value", GameLayer.roundStr, "RoundDiscriptor", GameLayer.logMsgArgument,GameLayer.logLevelArgument,TrainMapLayer.flagLogType,MAPSIZE,"" );

            }  

            //CHANGES DONE 7 FEB

        }
        else
        {
            Log.v("In else condition ccTouchesBegan", "))))))))))))))))");

        }
        return true;
    }

请帮助我

4

1 回答 1

2

您可以使用 CCMenuItemImage 进行触摸。像 :

CCMenuItemImage xyz= CCMenuItemImage.item("start.png", "start.png",this, "to_Where_You_Want_To_Replace_Your_Scene");
于 2013-03-01T08:04:37.333 回答