BasicCollider = class("BasicCollider", function()
local node = cc.Node:create()
node:setCascadeColorEnabled(true)
return node
end)function BasicCollider:ctor()
self.minRange = 0 --the min radius of the fan
self.maxRange = 150 --the max radius of the fan
self.angle = 120 --arc of attack, in radians
self.knock = 150 --default knock, knocks 150 units
self.mask = 1 --1 is Heroes, 2 is enemy, 3 ??
self.damage = 100
self.facing = 0 --this is radians
self.duration = 0
self.curDuration = 0
self.speed = 0 --traveling speed}
self.criticalChance = 0
end主要干了3件事:
[1]判断是否“打到了”
计算攻击单位转向目标需要的角度
判断是否在攻击区
if(afacing + attack.angle/2)>angle and angle > (afacing- attack.angle/2) thenlocal pos1 = getPosTable(self) local pos2 = getPosTable(self) local pos3 = getPosTable(self) pos1.x = pos1.x+130 pos2.x = pos2.x+330 pos3.x = pos3.x+530 pos1 = cc.pRotateByAngle(pos1, self._myPos, self._curFacing) pos2 = cc.pRotateByAngle(pos2, self._myPos, self._curFacing) pos3 = cc.pRotateByAngle(pos3, self._myPos, self._curFacing)
MageIceSpikes.create
随机由10个冰刺组成,并且添加粒子效果
_specialAttack = {
minRange = 0,
maxRange = 140,
angle = DEGREES_TO_RADIANS(360),
knock = 75,
damage = 250,
mask = EnumRaceType.HERO,
duration = 4.5,
speed = 0,
criticalChance = 0.05,
DOTTimer = 0.75, --it will be able to hurt every 0.5 seconds
curDOTTime = 0.75,
DOTApplied = false
},
GameMaster:init() 从中可以看到
统一把角色创建好,再分批放出来
self:AddHeros()int lua_cocos2dx_ParticleSystemQuad_create(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"cc.ParticleSystemQuad",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 1)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.ParticleSystemQuad:create");
if (!ok) { break; }
cocos2d::ParticleSystemQuad* ret = cocos2d::ParticleSystemQuad::create(arg0);
object_to_luaval<cocos2d::ParticleSystemQuad>(tolua_S, "cc.ParticleSystemQuad",(cocos2d::ParticleSystemQuad*)ret);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 0)
{
cocos2d::ParticleSystemQuad* ret = cocos2d::ParticleSystemQuad::create();
object_to_luaval<cocos2d::ParticleSystemQuad>(tolua_S, "cc.ParticleSystemQuad",(cocos2d::ParticleSystemQuad*)ret);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 1)
{
cocos2d::ValueMap arg0;
ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0, "cc.ParticleSystemQuad:create");
if (!ok) { break; }
cocos2d::ParticleSystemQuad* ret = cocos2d::ParticleSystemQuad::create(arg0);
object_to_luaval<cocos2d::ParticleSystemQuad>(tolua_S, "cc.ParticleSystemQuad",(cocos2d::ParticleSystemQuad*)ret);
return 1;
}
} while (0);
ok = true;ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.ParticleSystemQuad:create");
而error log就是在尝试得过程中函数 luaval_to_native_err 报出来的
if (!tolua_iscppstring(L,lo,0,&tolua_err))
{
#if COCOS2D_DEBUG >=1
luaval_to_native_err(L,"#ferror:",&tolua_err,funcName);
#endif
ok = false;
}参考:
cocos2dx 3d开源项目 fantasyWarrior3D 从零走起 6完结 [AttackManager&GameMaster]
原文地址:http://blog.csdn.net/goodeveningbaby/article/details/41859025