News:

Welcome to the new Sinister Design forums!

Main Menu

Ask the developer a question!

Started by CraigStern, February 07, 2010, 11:01:17 AM

Previous topic - Next topic

HeadShot

WARNING: This is going to be possibly the stupidest question EVER!!!!!!

How do you get affinitys? (Told ya)
My head got shot up once. And I lived and my head Remained.....

CraigStern

Once you get far enough in the plot, something happens where you can get your affinity. You're almost guaranteed to stumble onto it sooner or later. ;)

HeadShot

that explains it.  :(

Something is wrong with the Windows Demo. Can you fix it? (Sorry for wrong topic, Just want it fixed)
My head got shot up once. And I lived and my head Remained.....

CraigStern

Quote from: TheCerzakfan81 on December 27, 2010, 03:17:53 PM
that explains it.  :(

Something is wrong with the Windows Demo. Can you fix it? (Sorry for wrong topic, Just want it fixed)

Are you talking about the fact that it generates a shortcut file that doesn't work? I'm aware of that--I'm actually planning to upload an updated downloadable Windows demo later today which will hopefully address that issue.

HeadShot

Thanks.

I'll edit this when I have a question.
My head got shot up once. And I lived and my head Remained.....

Xemadus Echina

I just bought the pre-order! where's my activation code? I can't find it in the emails :(
im writing a book!
http://sinisterdesign.net/forum/index.php?topic=236.0;topicseen
heres a free verse poem I wrote for school
You never know
Just what you will find after you
Lost your favorite thing. But
The important thing is that the
Game you play will help you to get by.

CraigStern

Look for the part of the email that reads

QuoteThe product registration key is: blah blah blah

Zackirus

Is Rahel's Guard Informant Name Rajav? 
If The World Was A Bit More Like Canada, Then We Would Have A Great World, And Hockey 24/7

- Lord Canada

ArtDrake

I am, once again, working on a game that I halted work on months ago, not understanding AS3 well enough to pull it off. Now, with the right knowledge, I think I can do it, but Flash isn't registering my keyboard input (the lack of an IsDown method is bothersome, to say the least). There are no errors or exceptions, so I think that I've simply stated something wrong. If you have time to take a look at the code, it would help:

var leftIsDown:Boolean = false;
var rightIsDown:Boolean = false;
var upIsDown:Boolean = false;
var downIsDown:Boolean = false;

...

addEventListener(KeyboardEvent.KEY_DOWN, onDown, true, 0);
addEventListener(KeyboardEvent.KEY_UP, onUp);

...

public function onDown(k:KeyboardEvent):void {
trace("hi");
switch(k.keyCode){
case Keyboard.LEFT:
leftIsDown = true;
break;
trace(leftIsDown);
case Keyboard.RIGHT:
rightIsDown = true;
break;
case Keyboard.UP:
upIsDown = true;
break;
case Keyboard.DOWN:
downIsDown = true;
break;
}
}
public function onUp(k:KeyboardEvent):void {
switch(k.keyCode){
case Keyboard.LEFT:
leftIsDown = false;
break;
trace(leftIsDown);
case Keyboard.RIGHT:
rightIsDown = false;
break;
case Keyboard.UP:
upIsDown = false;
break;
case Keyboard.DOWN:
downIsDown = false;
break;
}
}


The trace function isn't making output when I press keys. Do you have any idea what could be causing this?

CraigStern

It could be a few things. I never use switch myself, so I can't confirm that you're using the syntax correctly. Assuming that you are, I've found that Flash can be quite temperamental if you don't place your keyboard listener in the document class. If it's not in your document class right now, I would move it there and turn those onUp / onDown handlers into regular functions. I would then create some new handlers in the document class that feed the keyCode directly to your onDown and onUp functions as arguments.

I hope that helps!

ArtDrake

Alas, I do all you suggest, and to no avail. I was working in my document class, but I can see where it would be finnicky like that.

Was your meaning that I should add functions like this?:

function onDownEvent (k:KeyboardEvent):void {
var kn:KeyboardEvent = k;
onDown(kn.keyCode);
}

function onUpEvent (k:KeyboardEvent):void {
var kn:KeyboardEvent = k;
onUp(kn.keyCode);
}


And have the beginning of the onDown/Up functions look like this?:

function onDown(k:Number):void {


Even though it doesn't seem to solve the problem, whatever that is, is would make my code easier to modify and install later functionality in.

I think that problem is that the event isn't even dispatched, and that perhaps the problem is one lying in my computer.

Thank you for taking the time!

CraigStern

It could also be those last two arguments in your KEY_DOWN listener. I've never seen those used before. Try removing them.

This is what I was talking about as far as the handlers (no need to add an extra variable into the mix):

function onDownEvent ( k:KeyboardEvent ):void {
mainGameClass.onDown( k.keyCode );
}

function onUpEvent (k:KeyboardEvent):void {
mainGameClass.onUp( k.keyCode );
}

ArtDrake

The two extra arguments were something I added when it wasn't working, ironically enough. The zero is a priority setting, meaning that that particular event listener gets n priority in dispatching. The higher the number, the higher the priority. It's useful when you don't want one event firing before another gets a chance to, say, clear an array.

The true is the variable "isWeakReference", and I was reading in a book about best practices in Flash Programming that unless you have a good reason to do otherwise, setting isWeakReference to true is a good idea. If the reference is weak, and if whatever object dispatching the event is sent to the Heap, the reference is also garbage-collected. If you have all strong references, they tend to just pile up.

Once again, thanks for all the help you've lent me, and I think I'll just run a simple program that only checks for KeyboardEvents, and try to isolate the error.

But now I have another question: do you encapsulate your getter methods and hash-check them whenever called, to prevent hacking? A few encryptions or hashes here and there (specifically when using a money variable) increase the non-hackability of the game. Not that the game is multiplayer, but just out of an interest to have people abide by the rules...

CraigStern

Something like this, you mean? It seems like an awful lot of effort to go through to prevent people from engaging in a victimless offense, especially when i could use that time to create content or fix bugs.

And with TSoG, I'm not even sure I could do it if I wanted to--the engine is (regrettably) coded in AS2.

bugfartboy

I've been lost the past few posts. I don't understand much of programming at all. But anyway: what plans do you have after TSoG is finished and released?