游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1254|回复: 3

新人代码求助.....

[复制链接]

1

主题

3

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2009-10-28 11:16:00 | 显示全部楼层 |阅读模式
  这段代码是关于控制物体自由下落的,但不知道如何改变其运动方向,现在是沿Z轴垂直下落,想让那物体沿ZY轴下落的话(例如加个向左的风,下落方向就要是沿左下下落)要怎么改...就是哪句是控制初始坐标和下落坐标....

  // ========================================================================
//  moveshape.cs
//
//  This module contains the definition of a test shape, which uses
//  a model of a stylized heart. It also contains functions for placing
//  the test shape in the game world and moving the shape.
// ========================================================================

datablock ItemData(TestShape)
// ----------------------------------------------------
//     Definition of the shape object
// ----------------------------------------------------
{
   // Basic Item properties
   shapeFile = "~/data/shapes/items/heart.dts";
   mass = 1;      //we give the shape mass and
   friction = 1;  // friction to stop the item from sliding
                  // down hills
};

function InsertTestShape()
// ----------------------------------------------------
//     Instantiates the test shape, then inserts it
//     into the game world roughly in front of the
//     the player's default spawn location.
// ----------------------------------------------------
{
   // An example function which creates a new TestShape object
   %shape = new Item() {
      datablock = TestShape;
      rotation = "0 0 1 0"; // initialize the values
                            // to something meaningful
   };
   MissionCleanup.add(%shape);

   // Player setup
   %shape.setTransform("-90 -2 20 0 0 1 0");
   echo("Inserting Shape " @ %shape);
   return %shape;
}

function MoveShape(%shape, %dist)
// ----------------------------------------------------
//     moves the %shape by %dist amount
// ----------------------------------------------------
{
   %xfrm = %shape.getTransform();
   %lx = getword(%xfrm,0); // get the current transform values
   %ly = getword(%xfrm,1);
   %lz = getword(%xfrm,2);
   %lx += %dist;          // adjust the x axis position
   %shape.setTransform(%lx SPC %ly SPC %lz SPC "0 0 1 0");
}

function DoMoveTest()
// ----------------------------------------------------
//     a function to tie together the instantiationinstantion
//     and the movement in one easy to type function
//     call.
// ----------------------------------------------------
{
   %ms = InsertTestShape();
   MoveShape(%ms,15);
}
贴上代码,求贤者指教...

1

主题

3

帖子

0

积分

新手上路

Rank: 1

积分
0
 楼主| 发表于 2009-10-28 22:26:00 | 显示全部楼层

Re:新人代码求助.....

喔喔..- -!真的...没人....么...
还是我发错地方了???? [em7]

0

主题

4

帖子

10

积分

新手上路

Rank: 1

积分
10
发表于 2009-10-29 00:17:00 | 显示全部楼层

Re:新人代码求助.....

不会C# 下面是百度找的,建议你有问题最好百度试试,呵呵
function MoveShape(%shape, %dist, %flag)
{//移动物体
    if(!isObject(%shape))
       return;
    %xfrm=%shape.getTransform();
    %lx=getWord(%xfrm, 0);
    %ly=getWord(%xfrm, 1);
    %lz=getWord(%xfrm, 2);
    if(%flag==1)
    {//沿x轴方向移动
       %lx+=%dist;
       %lz= getHeight(%lx, %ly);
    }
    elseif(%flag==2)
    {//沿y轴方向移动
       %ly+=%dist;
       %lz= getHeight(%lx, %ly);
    }
    Else   //沿z轴方向移动
       %lz+=%dist;
    %shape.setTransform(%lxSPC%lySPC%lzSPC"0 0 1 0");
}


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/miranda2002/archive/2008/03/15/2184627.aspx

1

主题

3

帖子

0

积分

新手上路

Rank: 1

积分
0
 楼主| 发表于 2009-11-2 20:26:00 | 显示全部楼层

Re: Re:新人代码求助.....

warmtrue: Re:新人代码求助.....

不会C# 下面是百度找的,建议你有问题最好百度试试,呵呵
function MoveShape(%shape, %dist, %flag)
{//...

好的...3Q....之前不会找...(现在学习百度了...呵呵)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-18 09:33

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表