ForumsProgramming ForumFlash game help

12 4451
andyhunter
offline
andyhunter
30 posts
Nomad

Does any one know how to make a store in a flash game? where you click on buttons in the store to buy things. Because I tried to in my game but couldn't get it to work.

  • 12 Replies
PixelSmash
offline
PixelSmash
566 posts
Nomad

Well, why don't you show us what you have already? Perhaps there's a simple solution to your problem

Darkroot
offline
Darkroot
2,763 posts
Peasant

It's pretty simple.

1. A button to enter/leave the store/shop
2. Button that perform some functions of buying
3. Some variables to subtract the rupee's that the player has

If that doesn't work tell us what you tried to do in your game and give us and example.

andyhunter
offline
andyhunter
30 posts
Nomad

The button to enter/ leave the shop works, but when I make buttons to unlock things in my game it doesn't work.
I've tried to make it when you press the button it makes a blank movie clip visible. So that when the blank Movie Clip is visible it will set the other movie clips to visible, But the blank MC becomes visible before I click the button.

andyhunter
offline
andyhunter
30 posts
Nomad

I want the store to be like the store in these games:
Flight
Army of Ages
Pogo swing

master565
offline
master565
4,104 posts
Nomad

I've tried to make it when you press the button it makes a blank movie clip visible. So that when the blank Movie Clip is visible it will set the other movie clips to visible, But the blank MC becomes visible before I click the button.


It seems more like there is a problem in your code that is making it become visible before it is supposed to. We can't help you unless you show us that snippet of code.
andyhunter
offline
andyhunter
30 posts
Nomad

I deleted the code because it didn't work. So right now I have a health power-Up in my game that is attached to the stage one every few seconds, so what I want to do is make it so that they have to click on the button in the store to buy it first before it starts attaching the itself to the stage

andyhunter
offline
andyhunter
30 posts
Nomad

the code right now that adds the health power-Ups to the game is:
class Health extends MovieClip
powerupTimer += 1;
if(powerupTimer > 240)
{
powerupTimer = 0;
_root.attachMovie("Health", "Health" + _root.getNextHighestDepth(), _root.getNextHighestDepth());
}

PixelSmash
offline
PixelSmash
566 posts
Nomad

Hmm, I must say the purpose (of the Health class) isn't entirely clear. The button in the store should be easy enough, just have it call a function where you enable the health powerup.

The class itself doesn't look like it will do that much however, if I'm reading it right you want it to attach a health movieclip every 240 frames (which is about every 8 seconds I suppose?)
You can change it in two ways: either create an interval using setInterval, or put the code you've written in an onEnterFrame function - which will require it to be attached to the root, I think. My AS2 is quite rusty, so I could get it wrong

Good luck!

andyhunter
offline
andyhunter
30 posts
Nomad

this code in my last post is the code on my car's onEnterFrame function telling it to add the health powerups. the code should really look like this:
powerupTimer += 1;
if(powerupTimer > 240)
{
powerupTimer = 0;
_root.attachMovie("Health", "Health" + _root.getNextHighestDepth(), _root.getNextHighestDepth());
}

andyhunter
offline
andyhunter
30 posts
Nomad

the code for my Health power up is this:
class Health extends MovieClip
{
var speed;
function onLoad()
{
speed = 20;
_y = 100;
_x = Math.random()*600 + 155;
}
function onEnterFrame()
{
_y += speed;

if(this.hitTest(_root.car))
{
_root.car.updateHealth(100 - _root.car.health);
this.removeMovieClip();
}
if( _x < -30 || _root.car._visible == false)
{
this.removeMovieClip();
}
}
}

andyhunter
offline
andyhunter
30 posts
Nomad

I basically I don't want the health powerups to be added into my game until I click the button to buy it from the store.

andyhunter
offline
andyhunter
30 posts
Nomad

click hereto see my full code.

Showing 1-12 of 12