Basketball Camp
LiveCode Files for this Project
Getting Started
We will build this stack together from scratch. Here are a few quick notes:
- We will build with dimensions suitable for the iPhone: 320 X 480
- You will need the three graphics above at the end of the project. When the time comes, just come back to this page and then right-click on each and choose "Save Image As..." and save the image to a location of your choice. You will then import the images into LiveCode (File > Import as Control > Image file...).
First Script for button "Move Offensive Player":
(Click here for a text file with these scripts.)
on mouseUp
set the moveSpeed to 200
put random(320) into varOffensivex
put random(480) into varOffensivey
put round(varOffensivex/2) into varDefensivex
put round(varOffensivey/2) into varDefensivey
move button "offensive" to varOffensivex, varOffensivey without waiting
wait 10 ticks
set the moveSpeed to 100
move button "defensive" to varDefensivex, varDefensivey
end mouseUp
Final Script for button "Move Offensive Player":
on mouseUp
set the moveSpeed to 200
//basketball court is 10 pixels from each side, so subtract 20 from screen dimensions for next two lines
put (the random of 300)+10 into varOffensivex
put (the random of 460)+10 into varOffensivey
put item 1 of the location of button "basket" into varBasketx
put item 2 of the location of button "basket" into varBaskety
put round (varBasketx + ((varOffensivex-varBasketx)/2) ) into varDefensivex
put round (varBaskety + ((varOffensivey-varBaskety)/2) ) into varDefensivey
move button "offensive" to varOffensivex, varOffensivey without waiting
wait 10 ticks
set the moveSpeed to 100
move button "defensive" to varDefensivex, varDefensivey
end mouseUp
Adding a skin to a button (one approach)
- Create a substack
- Insert (or paste) images you want to use as skins to the card in the substack
- Add this script to the card in the main stack containing the button you want skinned:
on opencard
set the icon of button "offensive" to {IDNumberOfImage}
end opencard