赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 0 |
经验 | 0 |
最后登录 | 2010-6-20 |
在线时间 | 0 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 150
- 在线时间
- 0 小时
- 注册时间
- 2010-6-16
- 帖子
- 3
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
这貌似是个网游的脚本
进入游戏到了输入账号密码的地方后会提示
按确定后弹出
即下面的代码
- module Mouse
- #============================================================================
- # 设置
- #============================================================================
- # 动画的图片格式
- FORMAT_ANIMSRC_FRAMES_PER_ROW = 5; # 每一行几帧
- FORMAT_ANIMSRC_WIDTH_PER_FRAME = 40; # 每一帧对应的图像宽度
- FORMAT_ANIMSRC_HEIGHT_PER_FRAME = 28; # 每一帧对应的图像高度
- # 动画图片的数组枚举 (如果自己知道哪里是什么动画, 也可以不要用)
- ENUM_SCENE_MAP_MOUSELBUTTON_DOWN_ANIM_INDEX = 0 ; # 地图的鼠标动画的索引
- # 动画的数据, 这5个彼此一一对应
- @@mouseAnimGraphics = [nil];
- @@mouseAnimFrame = [8];
- @@mouseAnimDurationPerFrame = [8];
- @@mouseAnimTimes = [3];
- @@mouseAnimTotalDuration = [0];
- @@mouseAnimInScreen = [false];
- @@mouseMapCoord = [[], []];
- #============================================================================
- # 设置
- #============================================================================
-
- def self.SetAnim(index, sprite, screen = false, frame = 8, durationPerFrame = 8)
- if (nil != @@mouseAnimGraphics[index])
- @@mouseAnimGraphics[index].dispose();
- end
- @@mouseAnimGraphics[index] = sprite;
- @@mouseAnimGraphics[index].src_rect.set(0, 0,
- FORMAT_ANIMSRC_WIDTH_PER_FRAME,
- FORMAT_ANIMSRC_HEIGHT_PER_FRAME
- );
- @@mouseAnimInScreen[index] = screen;
- @@mouseAnimGraphics[index].visible = false;
- @@mouseAnimFrame[index] = frame;
- @@mouseAnimDurationPerFrame[index] = durationPerFrame;
- @@mouseAnimTotalDuration[index] = 0;
- @@mouseMapCoord[0][index] = 0;
- @@mouseMapCoord[1][index] = 0;
- end
- def self.StartAnim(index, x, y, times = 2)
- if (nil == @@mouseAnimGraphics[index])
- return false;
- end
- if (@@mouseAnimInScreen[index])
- @@mouseAnimGraphics[i].x = x;
- @@mouseAnimGraphics[i].y = y;
- else
- @@mouseMapCoord[0][index] = x;
- @@mouseMapCoord[1][index] = y;
- end
- @@mouseAnimGraphics[index].visible = true;
- @@mouseAnimTotalDuration[index] = @@mouseAnimFrame[index] *
- @@mouseAnimDurationPerFrame[index];
- @@mouseAnimTimes[index] = times;
- return true;
- end
- # 更新所有动画
- def self.UpdateAnim()
- @@mouseAnimTotalDuration.each_index{
- |i|
- if (0 >= @@mouseAnimTotalDuration[i])
- @@mouseAnimGraphics[i].visible = false;
- next;
- end
- @@mouseAnimTotalDuration[i] -= 1;
- if (!@@mouseAnimInScreen[i])
- @@mouseAnimGraphics[i].x = (((@@mouseMapCoord[0][i]<<7) - $game_map.display_x + 3)>>2) + 16;
- @@mouseAnimGraphics[i].y = (((@@mouseMapCoord[1][i]<<7) - $game_map.display_y + 3)>>2) + 32;
- end
- if (0 == (@@mouseAnimTotalDuration[i] % @@mouseAnimDurationPerFrame[i]))
- bmpRectIndex = @@mouseAnimTotalDuration[i] /
- @@mouseAnimDurationPerFrame[i];
- bmpRectIndexW = bmpRectIndex % FORMAT_ANIMSRC_FRAMES_PER_ROW;
- bmpRectIndexH = bmpRectIndex / FORMAT_ANIMSRC_FRAMES_PER_ROW;
- @@mouseAnimGraphics[i].src_rect.set(
- bmpRectIndexW * FORMAT_ANIMSRC_WIDTH_PER_FRAME,
- bmpRectIndexH * FORMAT_ANIMSRC_HEIGHT_PER_FRAME,
- FORMAT_ANIMSRC_WIDTH_PER_FRAME, FORMAT_ANIMSRC_HEIGHT_PER_FRAME
- );
- end
- }
- end
- # 更新指定的动画
- def self.UpdateAnimSpecial(indexArr)
- indexArr.each{
- |i|
- if (0 >= @@mouseAnimTotalDuration[i])
- @@mouseAnimTimes[i] -= 1;
- if (0 >= @@mouseAnimTimes[i])
- @@mouseAnimGraphics[i].visible = false;
- else
- @@mouseAnimTotalDuration[i] = @@mouseAnimFrame[i] *
- @@mouseAnimDurationPerFrame[i];
- end
- next;
- end
- @@mouseAnimTotalDuration[i] -= 1;
- if (!@@mouseAnimInScreen[i])
- @@mouseAnimGraphics[i].x = (((@@mouseMapCoord[0][i]<<7) - $game_map.display_x + 3)>>2) + 16;
- @@mouseAnimGraphics[i].y = (((@@mouseMapCoord[1][i]<<7) - $game_map.display_y + 3)>>2) + 32;
- end
- if (0 == (@@mouseAnimTotalDuration[i] % @@mouseAnimDurationPerFrame[i]))
- bmpRectIndex = @@mouseAnimTotalDuration[i] /
- @@mouseAnimDurationPerFrame[i];
- bmpRectIndexW = bmpRectIndex % FORMAT_ANIMSRC_FRAMES_PER_ROW;
- bmpRectIndexH = bmpRectIndex / FORMAT_ANIMSRC_FRAMES_PER_ROW;
- @@mouseAnimGraphics[i].src_rect.set(
- bmpRectIndexW * FORMAT_ANIMSRC_WIDTH_PER_FRAME,
- bmpRectIndexH * FORMAT_ANIMSRC_HEIGHT_PER_FRAME,
- FORMAT_ANIMSRC_WIDTH_PER_FRAME, FORMAT_ANIMSRC_HEIGHT_PER_FRAME
- );
- end
- }
- end
- # 等待完成的更新
- def self.UpdateAnimWait(indexArr, wait)
- indexArr.each{
- |i|
- if (0 >= @@mouseAnimTotalDuration[i])
- @@mouseAnimTimes[i] -= 1;
- if (wait)
- @@mouseAnimTotalDuration[i] = @@mouseAnimFrame[i] *
- @@mouseAnimDurationPerFrame[i];
- if (0 >= @@mouseAnimTimes[i])
- @@mouseAnimTimes[i] = 1
- end
- else
- @@mouseAnimTotalDuration[i] = @@mouseAnimTimes[i] = 0;
- end
- if (0 >= @@mouseAnimTimes[i])
- @@mouseAnimGraphics[i].visible = false;
- end
- next;
- end
- @@mouseAnimTotalDuration[i] -= 1;
- if (!@@mouseAnimInScreen[i])
- @@mouseAnimGraphics[i].x = (((@@mouseMapCoord[0][i]<<7) - $game_map.display_x + 3)>>2) + 16;
- @@mouseAnimGraphics[i].y = (((@@mouseMapCoord[1][i]<<7) - $game_map.display_y + 3)>>2) + 32;
- end
- if (0 == (@@mouseAnimTotalDuration[i] % @@mouseAnimDurationPerFrame[i]))
- bmpRectIndex = @@mouseAnimTotalDuration[i] /
- @@mouseAnimDurationPerFrame[i];
- bmpRectIndexW = bmpRectIndex % FORMAT_ANIMSRC_FRAMES_PER_ROW;
- bmpRectIndexH = bmpRectIndex / FORMAT_ANIMSRC_FRAMES_PER_ROW;
- @@mouseAnimGraphics[i].src_rect.set(
- bmpRectIndexW * FORMAT_ANIMSRC_WIDTH_PER_FRAME,
- bmpRectIndexH * FORMAT_ANIMSRC_HEIGHT_PER_FRAME,
- FORMAT_ANIMSRC_WIDTH_PER_FRAME, FORMAT_ANIMSRC_HEIGHT_PER_FRAME
- );
- end
- }
- end
- # 不消除动画的更新
- def self.UpdateAnimWait_Visible(indexArr, wait)
- indexArr.each{
- |i|
- if (0 >= @@mouseAnimTotalDuration[i])
- @@mouseAnimTimes[i] -= 1;
- if (wait)
- @@mouseAnimTotalDuration[i] = @@mouseAnimFrame[i] *
- @@mouseAnimDurationPerFrame[i];
- if (0 >= @@mouseAnimTimes[i])
- @@mouseAnimTimes[i] = 1
- end
- else
- @@mouseAnimTotalDuration[i] = @@mouseAnimTimes[i] = 0;
- end
- if (0 >= @@mouseAnimTimes[i])
- @@mouseAnimGraphics[i].visible = false;
- end
- next;
- end
- @@mouseAnimTotalDuration[i] -= 1;
- if (!@@mouseAnimInScreen[i])
- @@mouseAnimGraphics[i].x = (((@@mouseMapCoord[0][i]<<7) - $game_map.display_x + 3)>>2) + 1;
- @@mouseAnimGraphics[i].y = (((@@mouseMapCoord[1][i]<<7) - $game_map.display_y + 3)>>2) + 8;
- end
- if (0 == (@@mouseAnimTotalDuration[i] % @@mouseAnimDurationPerFrame[i]))
- bmpRectIndex = @@mouseAnimTotalDuration[i] /
- @@mouseAnimDurationPerFrame[i];
- bmpRectIndexW = bmpRectIndex % FORMAT_ANIMSRC_FRAMES_PER_ROW;
- bmpRectIndexH = bmpRectIndex / FORMAT_ANIMSRC_FRAMES_PER_ROW;
- @@mouseAnimGraphics[i].src_rect.set(
- bmpRectIndexW * FORMAT_ANIMSRC_WIDTH_PER_FRAME,
- bmpRectIndexH * FORMAT_ANIMSRC_HEIGHT_PER_FRAME,
- FORMAT_ANIMSRC_WIDTH_PER_FRAME, FORMAT_ANIMSRC_HEIGHT_PER_FRAME
- );
- end
- }
- end
- def self.ResetAnim(index)
- @@mouseAnimTotalDuration[index] = @@mouseAnimFrame[index] *
- @@mouseAnimDurationPerFrame[index];
- end
- def self.GetAnimTotalDuration(index)
- return @@mouseAnimTotalDuration[index];
- end
- def self.ReleaseAnim()
- @@mouseAnimGraphics.each{
- |sprite|
- next if (nil == sprite);
- sprite.dispose;
- sprite = nil;
- }
- end
- def self.TransMousPosToMapCoord()
- x, y = Mouse.get_mouse_pos();
- return [($game_map.display_x>>7) + (x>>5), ($game_map.display_y>>7) + (y>>5)];
- end
- def self.GetAnimTransCoord(index)
- return [@@mouseMapCoord[0][index], @@mouseMapCoord[1][index]];
- end
- end
- #=====================================================
- # 添加鼠标动画的方法
- spr = Sprite.new;
- spr.z = 99999999;
- spr.bitmap = Bitmap.new("mousepp.png");
- Mouse.SetAnim(Mouse::ENUM_SCENE_MAP_MOUSELBUTTON_DOWN_ANIM_INDEX, spr);
- END{Mouse.ReleaseAnim();}
- class Scene_Map
- alias updateMouseAnim update
- def update
- updateMouseAnim;
- x, y = Mouse.get_mouse_pos();
- Mouse.UpdateAnimWait_Visible([Mouse::ENUM_SCENE_MAP_MOUSELBUTTON_DOWN_ANIM_INDEX],
- $game_player.moving?);
- if (Mouse.press?(Mouse::LEFT))
- sprX, sprY = Mouse.TransMousPosToMapCoord()
- Mouse.StartAnim(Mouse::ENUM_SCENE_MAP_MOUSELBUTTON_DOWN_ANIM_INDEX,
- sprX, sprY);
- end
- end
- end
复制代码 220行为 spr.bitmap = Bitmap.new("mousepp.png");
求高手指教啊 在线=========啊 |
|