主题:  怎样用Lingo发射子弹?

5D蚂蚁

职务:普通成员
等级:2
金币:1.0
发贴:355
#12001/3/28 11:27:51
请问各位高手,我想用Lingo来控制一个发射子弹的程序,不知怎样来做?比如说手枪为演员“GUN”,子弹演员为“bullet”,我该怎样来实现?
要在“on mousedown” 时发射子弹且在“on mouseup”之前连续发射。

编辑历史:[这消息被黑蚂蚁编辑过(编辑时间2001-03-28 12:11:50)]


酷狗

职务:版主
等级:2
金币:10.0
发贴:610
#22001/3/28 15:08:13
要将if the mousedown放在on exitFrame me中并用go to the frame在本帧中循环,不能用for语句来控制,不然其它角色就不能动了。我没有做过,想来应该这样



5D蚂蚁

职务:普通成员
等级:2
金币:1.0
发贴:355
#32001/3/28 17:10:03
谢谢!
OH还忘了!!!当鼠标"up"时子弹应该继续飞行!直到飞出屏幕。如此才能实现子弹飞行的效果,那么怎样实现呢?
我用如下语句时子弹只能按一下走一下,鼠标一抬起就会停下但不能继续走下去。
on exitFrame
if the mousedown then
sprite(1).locv=sprite(1).locv-2
end if
go to the frame
end

编辑历史:[这消息被黑蚂蚁编辑过(编辑时间2001-03-28 17:16:54)]


dexn

职务:普通成员
等级:1
金币:1.0
发贴:157
#42001/3/28 21:40:56
用属性,
on mousedown
pmove=true
end
on mouseup
pmove=false
end
on exitframe
if pmove then
sprite(1).locv=sprite(1).locv-2
end if
end



D计划-混沌

职务:管理员
等级:6
金币:15.2
发贴:3528
#52001/3/28 22:11:25
on startmovie
global shots
set shots=0
end
-----------------------
on exitFrame me
global shots
if shots<>0 then
repeat with i = 1 to shots
sprite(I+).locv= sprite(I+).locv-
end repeat
end if
if the mousedown then
startTimer
repeat while the timer <
end repeat
if shots< then
set shots=shots+1
end if
end if
end if
end
未经验证,仅拱参考

编辑历史:[这消息被54zq编辑过(编辑时间2001-03-28 22:13:10)]


5D蚂蚁

职务:普通成员
等级:2
金币:1.0
发贴:355
#62001/3/30 14:01:30
在一个子弹发射的例子中有这样一段程序:
on fire me, loc
if pMode = #fire then
sendSprite(sprite(me.spriteNum+1),#fire,loc)
else
sprite(me.spriteNum).loc = loc
pMode = #fire
end if
end

谁知道"sendSprite(sprite(me.spriteNum+1),#fire,loc)"是何意?怎么用?



dexn

职务:普通成员
等级:1
金币:1.0
发贴:157
#72001/3/30 14:12:28
sendSprite(sprite(me.spriteNum+1),#fire,loc)
给指定的通道上的精灵发送一个消息,让它执行指定的行为
sendSprite(指定的通道上的精灵,行为,参数)
还有一个是sendallSprite,发送的对象是所有含有指定行为的精灵。



5D蚂蚁

职务:普通成员
等级:2
金币:1.0
发贴:355
#82001/3/30 16:14:46
多谢!!
在控制子弹的发射时好象"sendsprite"可以用上而且起不小的功能。但现在还没有实现此功能。希望高手指点。

编辑历史:[这消息被黑蚂蚁编辑过(编辑时间2001-03-30 16:22:40)]


dexn

职务:普通成员
等级:1
金币:1.0
发贴:157
#92001/3/30 16:52:11
my.6to23.com/dexn/shotings.zip

嘿嘿,就是看你跟小雨都提这问题,我才写的,他已经下了,你怎么还没有呀!



5D蚂蚁

职务:普通成员
等级:2
金币:1.0
发贴:355
#102001/4/2 10:06:25
谢谢,我试一下吧!————————————————————
OH!My god!!我用的是7.0。

————————————————
上次54zq的程序
on startmovie
global shots
set shots=0
end
-----------------------
on exitFrame me
global shots
if shots<>0 then
repeat with i = 1 to shots
sprite(I+).locv= sprite(I+).locv-
end repeat
end if
if the mousedown then
startTimer
repeat while the timer <
end repeat
if shots< then
set shots=shots+1
end if
end if
end if
end
未经验证,仅拱参考
谢谢54zq的“指示”,但这段程序我早就知道了。
我想实现的是鼠标第一次点击时发射,第二次点击时发射第二颗,如果鼠标不抬起的话,将连续发射?

编辑历史:[这消息被黑蚂蚁编辑过(编辑时间2001-04-02 10:21:13)]


D计划-混沌

职务:管理员
等级:6
金币:15.2
发贴:3528
#112001/4/2 12:00:51
试过吗,ok,我没试过(sorry,是在网吧写的)
但又看了一遍,认为可以达到你要的效果
主要是在 on mousedown后加一延时来发送子弹(延时比较小,甚至可以去掉)
每单击一次发一科,然后满足几次延时发几颗
当然,上面的延时是对整体子弹速度有影响的,可改用其他方法(比如改repeat 为if)