我在 XNA 中有一个工作 2D 相机,具有以下功能:
ms = Mouse.GetState();
msv = new Vector2(ms.X, ms.Y); //screenspace mouse vecor
pos = new Vector2(0, 0); //camera center of view
zoom_center = cursor; //I would like to be able to define the zoom center in world coords
offset = new Vector2(scrnwidth / 2, scrnheight / 2);
transmatrix = Matrix.CreateTranslation(-pos.X, -pos.Y, 0)
* Matrix.CreateScale(scale, scale, 1)
* Matrix.CreateTranslation(offset.X, offset.Y, 0);
inverse = Matrix.Invert(transmatrix);
cursor = Vector2.Transform(msv, inverse); //the mouse position in world coords
Run Code Online (Sandbox Code Playgroud)
我可以移动相机位置并更改缩放级别(为简洁起见,我没有在此处粘贴其他代码)。相机始终围绕屏幕中心进行缩放,但我希望能够围绕任意缩放点(在这种情况下为光标)进行缩放,例如独立游戏dyson http://www.youtube.com/watch? v=YiwjjCMqnpg&feature=player_detailpage#t=144s …
我有一个小的.m文件,我在MATLAB R2010b中通过F5在编辑器中按下来运行.这是文件:
clear all, close all, clc;
%why are you printing !?
a = 1
c = eye(5);
Run Code Online (Sandbox Code Playgroud)
我希望这个代码在运行时显示以下内容:
a =
1
Run Code Online (Sandbox Code Playgroud)
但相反它显示了这个:
%why are you printing !?
a = 1
a =
1
c = eye(5);
Run Code Online (Sandbox Code Playgroud)
如果我从控制台调用该文件,则会发生相同的行为.我无法在互联网上或在MATLAB的控制台设置中找到任何更改此信息.我使用过许多不同版本的MATLAB,这在以前从未发生过.
Lists的.Last()方法仅返回一个值.我希望能够做到这样的事情.
List<int> a = new List<int> { 1, 2, 3 };
a.Last() = 4;
Run Code Online (Sandbox Code Playgroud)
这是我尝试编写扩展方法(它不编译)
public unsafe static T* mylast<T>(this List<T> a)
{
return &a[a.Count - 1];
}
Run Code Online (Sandbox Code Playgroud)
我想做什么?
编辑:
这是我想要使用它的一个例子.
shapes.last.links.last.points.last = cursor; //what I want the code to look like
//how I had to write it.
shapes[shapes.Count - 1].links[shapes[shapes.Count - 1].links.Count - 1].points[shapes[shapes.Count - 1].links[shapes[shapes.Count - 1].links.Count - 1].points.Count-1] = cursor;
Run Code Online (Sandbox Code Playgroud)
这就是做的原因
shapes[shapes.Count-1]
Run Code Online (Sandbox Code Playgroud)
不是一个真正的解决方案.