Card Game

Get help using Construct 2

Post » Thu Oct 27, 2011 2:42 pm

Hi guys,

I just downloaded construct 2 and it looks really fabulous. However I'm not too sure if it is really designed for what I had in mind. I have already developed a few card games in java/swing and so as a warm up I would like to have a go at this as my first project.

   From what I have seen would I have to crate 52 sprites with each one having its proper set of events which seems to be a bit of a nightmare or is it possible to have just 1 card sprite and to spawn 52 cards with different characteristics i.e. different graphics, instance variables to represent its suit and value etc.
   Secondly would i be able to drag and drop each one of these individually around the screen?

Cheers for any input.
B
1
G
1
Posts: 7
Reputation: 489

Post » Thu Oct 27, 2011 3:14 pm

Try making one sprite with 52 animation frames for each card. Set the animation speed to 0, then just use 'set animation frame' to change the card.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Thu Oct 27, 2011 3:23 pm

Sounds like a plan! Thanks for the idea I'll try it out straight away.
B
1
G
1
Posts: 7
Reputation: 489

Post » Thu Oct 27, 2011 4:01 pm

Ok I tried this out and it worked like a dream however (funny how there is always a but) I did the following little project to test it out so with 1 sprite and 52 animation frames and then when I did a mouse click i would spawn a card incrementally at the mouse location.
It worked like a charm but something weird happens as i click from about the 10th card onwards the card spawning time grows exponentially longer so by about 15 spawns i'm waiting like a minute to see the card (in chrome) here is the coding: original card sprite is invisible to start off with a global integer called cardNb.

<Mouse> <On any Click> <Card> Spawn Card on layer 1
                        <Card> set animation speed to 0
                        <Card> set visible
                        <Card> set position to (Mouse.x, Mouse.Y)
                        <Card> set animation frame to cardNb
                        <System> add 1 to cardNb
Have I coded something wrong or is this just a performance limit and so I could never have 52 cards spawned?
Regards
B
1
G
1
Posts: 7
Reputation: 489

Post » Thu Oct 27, 2011 4:06 pm

It's best to post your .capx file for Ashley or someone else to check out (if you don't mind others looking :D).

I've spawned HUNDREDS of Sprites each with individual actions and private variables and the game still ran fine... so maybe it's just a little glitch somewhere.
B
33
S
6
G
7
Posts: 338
Reputation: 7,424

Post » Thu Oct 27, 2011 4:11 pm

ok no problem except what is a .capx file and how do i post it?
cheers
B
1
G
1
Posts: 7
Reputation: 489

Post » Thu Oct 27, 2011 4:15 pm

.capx is the format of your project when you "Save as a single file" (basicly a .zip of a folder project).
To post it, check out this tutorial about dropbox.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Thu Oct 27, 2011 4:32 pm

Great I just learnt something new! Ok here is the link if anybody is
interested:
http://dl.dropbox.com/u/47181564/Solitaire.capx
I disabled the animation frame incrementation so now it basically just
spawns a king of hearts. When run just click on the green back ground and things should start slowing down around 15ish.
Cheers
B
1
G
1
Posts: 7
Reputation: 489

Post » Thu Oct 27, 2011 6:24 pm

I found the problem -- the event that says "Card - Spawn card etc. etc.". If you set text to display the number of cards, you'll see it's actually spawning in powers of two; 2, 4, 8, 16, 32, 64, until it reaches THOUSANDS of cards spawned in the same spot every time you click. Hence the slowdown.

You can fix it by switching out that line for "System - Create Card at Mouse.X, Mouse.Y". Accomplishes the same thing without that messy situation!
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Thu Oct 27, 2011 7:36 pm

Wow thank you Mr Sully The Strange! Onward with the adventure!
B
1
G
1
Posts: 7
Reputation: 489

Next

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, jul, nicklowkcmagic and 18 guests