.
102 Construct2 Create Card Game Templates
1) Create New Project.
Project Name=CardGameTemplates.
2) Insert Sprite Objects.
Create Object Group “Play” and insert objects SpriteCardPiece, SpriteCardLabel, SpriteCardFrame and SpriteCardHotSpot.
Name
|
SpriteCardPiece
|
Layer
|
0
|
Position
|
150,300
|
Size
|
100,100
|
Color (RGBA)
|
0,250,150,255
|
HotSpot
|
Center
|
Instance Variable
|
Name=SID, Type=Text
|
Name
|
SpriteCardLabel
|
Layer
|
0
|
Position
|
150,300
|
Size
|
80,80
|
HotSpot
|
Center
|
Instance Variable
| |
Horizontal Alignment
|
Center
|
Vertical Alignment
|
Center
|
Name
|
SpriteCardFrame
|
Layer
|
0
|
Position
|
150,150
|
Size
|
100,100
|
Color (RGB)
|
0,250,250,55
|
HotSpot
|
Center
|
Instance Variable
|
Name
|
SpriteCardHotSpot
|
Layer
|
0
|
Position
|
150,150
|
Size
|
10,10
|
Color (RGB)
|
0,0,0,0
|
HotSpot
|
Center
|
Instance Variable
|
Name=SID, Type=Text
|
OUTCOME.
3) Make SpriteCardFrame and SpriteCardPiece as containers.
Container=SpriteCardFrame, Member=SpriteCardHotSpot.
Container=SpriteCardPiece, Member=TextCardLabel.
4) Add Behavior to Objects.
SpriteCardPiece Behavior=Drag Drop, Flash and Pin.
TextCardLabel, Behavior=Pin.
5) Add On Start Of Layout Event to pin objects.
Add On Start Of Layout Event.
Add a new group “Pin CardLabel to CardPiece”.
Add Action to pin TextCardLabel to SpriteCardPiece.
OUTCOME.
TextCardLabel follows SpriteCardPiece when the latter is dragged by the player.
6) Add Actions For CardPiece Drag Drop Event.
Add a group “CardPiece Drag Drop” to the bottom of On Start Of Layout Event.
On Drag Start event, move SpriteCardPiece and TextCardLabel to top of layer.
On Drop and event and on condition SpriteCardPiece overlaps SpriteCardHotSpot, execute the following SpriteCardPiece actions:
Flash,
Position To SpriteCardHotSpot,
Pin to SpriteCardHotSpot.
No comments:
Post a Comment