XNA - Allowing mouse visibility - Where does the command go? - xna

So... Yeah.
I can't see the cursor in my game.
I've read here you have to place "this.IsMouseVisible=true;" somewhere in the main Game class constructor/initializer.
When I tried this, the "IsMouseVisible" wasn't recognized.
Any help?
Also: I've tried loading a texture for the cursor, follow the Mouse position and draw it, but with no success.

protected override void Initialize()
{
this.IsMouseVisible = true;
}
Maybe Initialize should do it? What exactly do you mean by "Not Recognized"

Related

It is normal to an infinite loop within the OnPaint event of a DataGridView?

I have the following code:
int a = 0;
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
base.OnPaint(e);
this.Rows[1].Cells[1].Value = a += 1;
}
and I can see that the variable increases to infinity. I'm using it to paint a graphic making an instance of it and it works fine.
Is this normal? I am creating infinite graph instance? Or I have a problem and I don't know
When you change the value, the grid needs to re-Paint itself., thus firing the Paint event again and re-executing your code.
This behavior is by design.
In general, you should never change external state in a Paint handler; drawing code should be idempotent (other than the provided Graphics).
Paint events are unpredicable and will fire very often.

Blackberry jumpy scroll

I am having trouble with vertical scrolling on a blackberry app.
it works just fine on touch screens, but when scrolling using a track pad, it jumps from being at the top position to being at the bottom position.
Anyone had a similar problem? any idea what i could try?
Here is a snippet from my code. i have a static background image and the fields scroll on top of it:
vertical_main = new VerticalFieldManager(USE_ALL_WIDTH |NO_VERTICAL_SCROLL |USE_ALL_HEIGHT);
vertical_AllTags=new VerticalFieldManager(USE_ALL_WIDTH | VERTICAL_SCROLL);
// i then add all the fields to vertical_AllTags
vertical_main.add(vertical_AllTags);
vertical_main.invalidate();
add(vertical_main);
thanks in advance for your help
EDIT:
The suggestion of giving each field focus was correct. the only other part that needs to be done is when you override the onFocus method for a field, you need to call the super() function so that all the other normal parts of the onFocus method are still called:
protected void onFocus(int direction) {
text_select=true;
invalidate();
super.onFocus(direction);
}
protected void onUnfocus() {
text_select=false;
invalidate();
super.onUnfocus();
}
Thank you so much.
This is common issue in non touch devises for beginners.
if you want to scroll field by field there is two ways
1) you need to give the focus to all fields then it will come field by
field focus down
another way is means you dont need to focus on each and every field
2)just add the NullField after your every field and give focus to all
NullFields then your trackball will bring your screen field by field
This happends beacuse in TrackWheel Scrolling it scrolls up to the next Focused field. I think you are not give any focus between the vertical_AllTags.
You can solved this by using NullField() class. Like...
add(new NullField(Field.FOCUSABLE))
when you add add(new NullField(Field.FOCUSABLE)); you will get the null focus which is not know by you. And you can navigate all the fields like Touch Screen.
You can solve that issue by adding two vertical field manager.. take a look at the code in this post

ActionScript 3 Mouse Out

I'm creating an animated (in and out) drop down menu.
I've managed to get the menu to open when the user mouses over, with the buttons all selectable.
However I can't seem to find an efficient method of making the drop down menu close whenever the mouse is not over the menu.
Actions:
Nav_Main_Sports.addEventListener(MouseEvent.MOUSE_OVER, Nav_Main_Sports_Open);
Nav_Main_Sports_Out.addEventListener(Event.MOUSE_LEAVE, Nav_Main_Sports_Close);
function Nav_Main_Sports_Open(event:MouseEvent):void
{
gotoAndPlay(2);
}
function Nav_Main_Sports_Close(event:MouseEvent):void
{
gotoAndPlay(14);
}
Stops are included, but on a separate layer.
All help would be appreciated. Thanks in advanced.
Actions:
Nav_Main_Sports.addEventListener(MouseEvent.ROLL_OVER, Nav_Main_Sports_Open);
Nav_Main_Sports.addEventListener(MouseEvent.ROLL_OUT, Nav_Main_Sports_Close);
function Nav_Main_Sports_Open(event:MouseEvent):void
{
Nav_Main_Sports.gotoAndPlay(2);
}
function Nav_Main_Sports_Close(event:MouseEvent):void
{
Nav_Main_Sports.gotoAndPlay(14);
}
Worked out the best method for this, use ROLL_OVER and ROLL_OUT and refer to the drop down menu in the function. This worked perfectly for me.
Try this:
Nav_Main_Sports.addEventListener(MouseEvent.MOUSE_OUT, Nav_Main_Sports_Close);
EDIT:
If you want to get the event on the whole swf, do stage.addEventListener(MouseEvent.MOUSE_OUT, Nav_Main_Sports_Close);

drawing lines, and getting error code # 1009

I'm having a problem I can't seem to solve. I'm making an animation wich draws a line after a moving object (circle on a guide line). This circle is a movieclip and I have many lines to draw up. So, I put many of them on separate scenes. I've created buttons from movieclips, and when pressed it draws a line. I got everything to work properly, but when one line is drawn, and you press the same button to get the same line drawn again I get the error code: #1009 cannot access a property or method of a null object reference.
I think that it's because the graphics is still there but I can't seem to clear it before it draws again. I have used graphics.clear(); but that just clears all, so when it "draws" again it doesn't show, only the movieclip-animation works. What is the problem here?
My code for the line drawing is:
import flash.display.Shape;
import flash.events.Event;
var shape = new Shape();
shape.graphics.lineStyle(2,0xFF0000);
shape.graphics.moveTo(ani1.x, ani1.y);
addChild(shape);
addEventListener(Event.ENTER_FRAME, loop);
function loop(event:Event):void
{
shape.graphics.lineTo(ani1.x, ani1.y);
}
and the code for the buttons is:
import flash.events.MouseEvent;
stop();
menu_button1.addEventListener (MouseEvent.CLICK, buttonClick);
function buttonClick (event:MouseEvent):void
{
gotoAndPlay(2, "AniDel1");
}
and all of the animations has a stop(); at the end.
i put together an example fla for you: anitest.fla.zip
hope this solves your problem.

Blackberry Maps closing oddly. Not Google maps

I'm having some trouble finding documentation on CLOSING a blackberry map.
My map opens, albeit with some odd marker behavior, but when you close the map it displays a clear screen.
The invoke code is quite simple, as the map request calls a new controller and within the constructor is this:
String document = "<location-document>... etc";
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments( MapsArguments.ARG_LOCATION_DOCUMENT, document));
I tried to add a close line
public boolean onClose() {
UiApplication.getUiApplication().popScreen(this);
return true;
}
but this is not being applied to the map itself, but the page the map opened into. That's logical, I guess.
Maybe I'm going about this all wrong. I don't know of how to open a map another way, or if there is a way to have the close button close the map AND the containing screen.
Any help is appreciated.
I solved this with a simple one line function that fixed this problem.
public void onExposed()
{
UiApplication.getUiApplication().popScreen(this);
}
Adding that to the map controller closes the map application when the user clicks the back button. Simple as that.

Resources