BritishGuile
40 posts
|
Topic: Game Programming /
AS2 SharedObject help?
Bless you. I can’t believe I missed such an obvious mistake i have been try to solve the problem for ages now.
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
AS2 SharedObject help?
Hi, I’ve never used shared objects before and I’m running into some trouble which I hope somebody can help me with. The code below is on a movie clip and when the player wins the game if the score they achieved is their highest I want the game to save it and hold that value as the “bestscore”. All that I can get from in when I try to display the best score in a dynamic text box is “undefined”.Can anybody advise or do I need to go into more detail?
onClipEvent (load) {
saveData = SharedObject.getLocal("SaveFileName");
if (saveData.data.exists == 1)
{
bestscore = saveData.data.bestscore;
}
else
{
bestscore = 0;
saveData.data.bestscore = bestscore;
saveData.data.exists = 1;
saveData.flush();
}
}
onClipEvent (enterFrame) {
bestscore = saveData.data.bestscore;
if (_root.player.win)
{
if (_root.player.score >= bestscore)
{
saveData.data.bestscore = _root.player.scorescore;
saveData.flush();
}
}
}
|
|
|
BritishGuile
40 posts
|
Topic: Game Design /
Best place to upload test games
Originally posted by GameBuilder15:
Originally posted by BritishGuile:
That wouldn’t work as people would need an account to see it wouldn’t they?
Dropbox has a public folder. If you give people the link they can access the file in the public folder.
Thanks that seems to work fine but is there a way to make it so the .swf is presented in its native dimensions. At present it is stretched to full screen automatically and shows objects that are out of frame
|
|
|
BritishGuile
40 posts
|
Topic: Game Design /
Best place to upload test games
That wouldn’t work as people would need an account to see it wouldn’t they?
|
|
|
BritishGuile
40 posts
|
Topic: Game Design /
Best place to upload test games
I have the opening level of a game I have been working on finished and would like to post it on-line so I can get some sort of feedback from friends and the like. I don’t want to just post it on kongregate or newgrounds as it is incomplete so I don’t want to clog the site with it and in addition I plan to get a sponsorship so limited views is preferable. Is there any site that you would recommend to me for this use, also the ability to delete the game at some point would be desirable.
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
[AS2] Reloading Frame
Is there a specific function that would remove all movieclips? currently only certain ones are specifically named.
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
[AS2] Reloading Frame
When my character dies I have it set to go to a previous frame that acts as a game over screen. however when the player clicks to retry the level the previous game remains with the old enemies and items overlapping. How would you recommend overcoming this issue?
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
Lag
Surely there must be a way to reduce lag in AS2?
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
Lag
How would I go about this, note I am using CS4 and AS2
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
Lag
I’m making a game and have the engine made but when placing in the graphic it has become extremely laggy. The graphics are all made in flash and are admittedly quite complex in shape but with lots of grids. Can aby of you suggest a solution to make the game run better, I’m not sure whether I should make as many objects as I can, convert the graphics to jpgs or what so any advice would be appreciated.
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
[AS2] Overlapping Enemies
I am making a top down shooter and all of the enemies are loaded on an array
if (enemyTimer > 100)
{
if (enemyDepth == 99)
{
enemyDepth = 0;
}
enemyDepth += 1;
enemyTimer = 0;
_root.attachMovie("enemy","enemy" + enemyDepth,enemyDepth);
}
I have got it so that the enemies move and chase the main character but after a while they seem to overlap each other a lot and just form one shape. Is there a way to make them detect if they are overlapping with another enemy and is so move to avoid it.
Below is the current code of my enemy movieclips
class enemy extends MovieClip
{
var speed:Number = 3;
var turnRate:Number = .3;
var moveX:Number = 0;
var moveY:Number = 0;
function onLoad()
{
speed = Math.random() * 5 + 1;
_x = Math.random() * 450 + 50;
_y = Math.random() * 350 + 50;
}
function onEnterFrame()
{
var distanceX:Number = _root.player._x - _x;
var distanceY:Number = _root.player._y - _y;
var distanceTotal:Number = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
var moveDistanceX:Number = turnRate * distanceX / distanceTotal;
var moveDistanceY:Number = turnRate * distanceY / distanceTotal;
moveX += moveDistanceX;
moveY += moveDistanceY;
var totalmove = Math.sqrt(moveX * moveX + moveY * moveY);
moveX = speed * moveX / totalmove;
moveY = speed * moveY / totalmove;
_x += moveX;
_y += moveY;
this._rotation = 180 * Math.atan2(moveY, moveX) / Math.PI;
}
}
|
|
|
BritishGuile
40 posts
|
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
[AS2] Instance Name Assistance
If you don’t know then yes it can be difficult. Also the code you provided doesn’t exacly solve my issue as the objects are randomly generated parts of the level and not enemies. I’ve put the piece were I think the issue is in below to better show the issue I’m having, because of the way the rest of the code for the gravity is I’m unsure on how to structure it all without breaking it.
grav++;
_y += grav;
while for(var i in _root.player.levels)
if(_root.player.levels[i].hitTest(_root.player))
{
_y--;
grav = 0;
}
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
[AS2] Instance Name Assistance
I do know how to run a hittest it is the array that I am unsure about as I explained in my oppening post as I am unfamilier with using them. In spite of this knowledge I am still not sure why that piece of code is necessary.
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
[AS2] Instance Name Assistance
Sorry for taking so long to respond but I tried what you suggested and got no further forward as the hit tests I run continue to fail. I currently have all the enemies in an array and am referencing them in hit tests as if(_root.player.eneyarray[i].hitTest) is there an error that I’m making? I noticed that in the shootorial they have the code “for(var i in _root.ship.enemies)” which I am missing is this the issue?
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
[AS2] Instance Name Assistance
I’m unsure how to explain this in a way that makes sense but so far in a game I’m making some of the objects that appear are generated at random this is done by an .as file. My issue is that I need to run a hit test between the player movie clip on each of these objects to allow for gravity ensure it doesn’t fall through. While I know how to do this with a movieclip on stage as the object movieclips are generated off the stage from a code they have no instance name I can reference to run the hittest. Is there a way to give them such a quality?
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
How do you generate a random number in as2
I’m trying to make it so that once a timer has run out a random enemy in generated and so enemies are generated at the correct intervals but I’m having trouble making the type of enemy generated random.
this is the code I have running once the timer runs out
enemyrandomizer == randomNumbers(1,2);
{
if(enemyrandomizer = 1)
{
_root.attachMovie("enemy1", "enemy1"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
}
if(enemyrandomizer = 2)
{
_root.attachMovie("enemy2", "enemy2"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
}
enemyrandomizer == 0;
} </p>
any ideas on what my issue might be
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
How do I remove a movie clip?
No thier all individual movieclips
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
How do I remove a movie clip?
Actually upon testing while this has solved my issue it has created another problem. When I have more than two enemies once the second one is killed all the others are removed from the stage as well. Any ideas why this may be
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
How do I remove a movie clip?
So currently I have one movieclip which you control, a second named which is an enemy and third which is a bullet. Using a similar piece of code to that which is taught in the shootorial the enemy regularly shoots bullets at you. In the bullets code I have
if(this.hitTest( _root.player) )
{
this.removeMovieClip();
}
this makes it so that if the bullet hits the player is is removed. As I want the enemy to be able to die I added the same piece of code to that movieclip however it doesn;t seem to work. Any suggestions for why this may be happening.
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
[AS2] Removing Movieclip Problem
In a small game I’ve been making I’ve hit an issue with the enemy movieclips and am looking for some suggestions on the solution. Currently on the enemy movieclip I have the following piece of code, the movie clips _root.player.attack1 and _root.player.attack2 are the attack animations of the player.
if(this.hitTest(_root.player.attack1) or (_root.player.attack2))
{
this.removeMovieClip()
}
With the code I aimed to remove the enemy movie clip once it is hit but for some reason it doesn’t seem to work. I’ve used the this.removeMovieClip() in other projects and it worked fine so I’m somewhat confused as to the issue here.
Edit:
A quick update my recent changes to the game have made it so the enemies are removed however it appears to affect every version of the enemy in the level. So in effect once one is hit every version of that movie clip is removed. Any suggestions yet?
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
Unexpected file format Error
My trial is still working and I can open other files its just the one I was working with that has a issue. Also I cant open it as a text document. Any other ideas?
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
Unexpected file format Error
I’m been working for a while now with a trial version of Flash CS5 and got quite alot of work done on a speciphic file, although this file has oppened numerous time over the past week I tried to open it today and recieved the erroe message “Unexpected file format”. I have an old backup but I had just solved some problems with the code and would like to get the file to open again. Any suggestions?
Also I know this isn’t directly related to programming but this is the most relevant forum and I was hoping you guys and gals could help me with this issue.
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
hit text question [AS2]
oh, ok that explains why that didn’t work as I planned
|
|
|
BritishGuile
40 posts
|
Topic: Game Programming /
hit text question [AS2]
is there not a way to make it search for all movieclips with the instance name of camera in out peice of code? I plan to have quite a few on each level of the game and the need to list them all seems very unefficiant.
|