Les 2 van het semester GameArt 3D, maak een waterton in 3D en texture deze via een uvw unwrap. In deze tutorial behandel ik lowpoly modeleren op vertex niveau. Verder komt aan bod; inset, extrude en bevel. Zie bovenstaande video tutorial voor uitleg over het 3D gedeelte, zorg zelf voor een texture.
News for the ‘tutorial’ Category
3DS max les 2, de waterton
Flash AS3 over variabelen
Variabelen binnen flash zijn handig, maar lastig om goed te implementeren. Daarom hier kort en bondig uitleg over hoe aan te maken en te gebruiken binnen je flash applicatie.
Als je een variabele aanmaakt en wil gebruiken in hetzelfde frame is er niets aan de hand, flash kan hem dan gewoon vinden. Het probleem is, als je op frame 1 een variabele aanmaakt en deze op bijvoorbeeld frame 12 pas wil hergebruiken.
Of als je ergens binnen een movieclip een variabele weer wil inlezen. Hieronder staan enkele mogelijkheden om deze variabelen overal uit te kunnen lezen.
1 2 3 4 5 6 7 8 9 | var deVariabeleNaam:String = de waarde; // je kunt de variabele overal benaderen als je het // volgende doet: MovieClip(this.root).deVariabeleNaam; // stel je hebt de variabele aangemaakt in een movieclip // dan gebruik je de volgende code: MovieClip(this.root).MovieClipInstanceNaam.deVariabeleNaam |
Onderstaande methode werkt alleen als je een var in een hoofdtijdlijn wil aanspreken.
1 2 3 4 | // variabele aanmaken met this ervoor zorgt dat deze op // de hoofdtijdlijn overal te vinden is. Uitlezen doe je // op dezelfde manier this.varName; |
Categories: flash as3, tutorial
Tags: as3, flash, var, variabelen. variable, vars
Comments: No Comments.
Flash AS3 variables and counting [EN]
To grow the flower, you have to turn on the light and give it water two times. You can do that in any order. You can only turn the light on one time. Since you can water it only two times, i used a little counter to check for the amount of clicks.
In the movieclips “flower” and “water” i placed stop(); codes to stop animations, until clicked again.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | var LightOn=false;//variable for the light, light is off var WaterCounter=0;//variable to count how many times water is being given, start value = 0 light.addEventListener(MouseEvent.CLICK, CheckLight);//turning the light on water.addEventListener(MouseEvent.CLICK, GivingWater);//giving water function CheckLight(evt:MouseEvent) { if (LightOn==false) {//if the light hasn't been turn on, else; do nothing light.nextFrame();//go to the next frame in the movieclip light (turns the light on) flower.play();//play the animation within the flower movieclip, until it encounters a stop(); LightOn=true;//the light has been turn on } } function GivingWater(evt:MouseEvent) { if (WaterCounter<=1) {//if you click water 2 times it will do this function (on 0 and 1) water.play();//play the animation within the movieclip water flower.play();//play the animation within the flower movieclip, until it encounters a stop(); WaterCounter++;//adds 1 to the variable WaterCounter } } |
Categories: flash as3, tutorial
Tags: as3, count, flash, tellen, variabelen, vars
Comments: No Comments.
Flash AS3 schalen met toetsenbord update
Op verzoek een update op het schalen met + en – toetsen. Nu moet je eerst het schilderij (de meest linkse) klikken, voordat je hem kunt gaan schalen. Door gebruik te maken van verschillende instance names en variabele namen, kun je dit toepassen op zo veel verschillende objecten in je scene als je wenst.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | var SchilderijClickStatus=false;//de click status van het schilderij op false zetten (er is niet op geklikt) Schilderij.addEventListener(MouseEvent.CLICK, SchilderijGeklikt);//luisteren of er op het schilderij geklikt wordt function SchilderijGeklikt(evt:MouseEvent) { SchilderijClickStatus=true;//zet de status van het schilderij op true, nu mag je hem schalen } stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPress); //een listener op de stage, die luisterd of er een toets ingedrukt wordt function onKeyPress(e:KeyboardEvent):void { if (SchilderijClickStatus==true) {//checked hier of de status van het schilderij true is, zo niet.. niets doen, anders schalen. if (e.keyCode == 187) {//als de keycode 187 is (+) Schilderij.scaleX += 0.5; //schaal 0.5 omhoog in de X-as Schilderij.scaleY += 0.5; //schaal 0.5 omhoog in de Y-as } if (e.keyCode == 189) {//als de keycode 189 is (-) Schilderij.scaleX -= 0.5; //schaal 0.5 omlaag in de X-as Schilderij.scaleY -= 0.5; //schaal 0.5 omlaag in de Y-as } } } |
Categories: flash as3, tutorial
Tags: as3, flash, keyboardevent, keycode, update
Comments: 4 Comments.
Flash AS3 drag and drop
Klik op de munt om hem te draggen, zodra je bij het varkentje komt verdwijnt de munt in het varken.
stage.addEventListener(MouseEvent.MOUSE_UP, drop);//bij loslaten van het muntje naar de functie drop
function drag(e:MouseEvent):void
{
e.target.startDrag(false, new Rectangle(33,31,559,230));//starten van het draggen, de rectangle is het gebied waar buiten het muntje niet kan gedragt worden (x,y,w,h)
}
function drop(e:MouseEvent):void
{
stopDrag();//stoppen van het draggen
}
munt.addEventListener(Event.ENTER_FRAME, Hitding); //luisteren of de munt het varkentje raakt
function Hitding(event:Event):void
{
if (spaarvarken.hitTestObject(munt)) // als het muntje het varkentje raakt
{
munt.visible=false;//wordt de munt onzichtbaar
}
}
In bovenstaand voorbeeld komt het muntje ook weer terug, om dat voor elkaar te krijgen heb je de volgende extra code nodig (onderstaande code komt bovenin):
var myTimer:Timer=new Timer(1000,30); //1000,30 betekend dat er 30 keer een seconde getimed wordt, aanpassen naar 60 voor een minuut.
myTimer.addEventListener(TimerEvent.TIMER, timerListener);//luisterd naar de timer
Vervang het laatste stuk code door de volgende codes:
{
if (spaarvarken.hitTestObject(munt)) // als het muntje het varkentje raakt
{
munt.visible=false;//wordt de munt onzichtbaar
myTimer.start();//start de timer
}
}
function timerListener(e:TimerEvent):void {
if (Teller==0) {//als de teller op 0 staat het volgende uitvoeren
munt.visible=true;//munt zichtbaar maken
munt.x=466.95;//verplaats naar deze x coordinaat
munt.y=200;//verplaats naar deze y coordinaat
Teller=10;//zet de teller weer op 10
myTimer.stop();//zet de teller stop
} else {
Teller–; //iedere seconde een afhalen van het getal in de variabele Teller
}
}
Categories: flash as3, tutorial
Tags: as3, drag and drop, flash, visible
Comments: No Comments.
Flash AS3 Custom muis cursor & vergrootglas
Beweeg de muis om het vergrootglas te bewegen, zodra je over de munten gaat komt er een glow om het vergrootglas (frame 2 binnen de movieclip die als muis gebruikt wordt).
function moveGlass(myEvent:MouseEvent) {
groot.x = (mouseX * -1); // groot is een tweede versie van je achtergrond, die groter op het scherm staat
groot.y = (mouseY * -1);
Glass_mc.x = (mouseX); //Glass_mc is een solid rondje (movieclip) die als masker dient voor de grotere versie van de achtergrond
Glass_mc.y = (mouseY);
Mouse.hide(); // verberg de normale muis
}
// checken of de muis beweegt
stage.addEventListener(MouseEvent.MOUSE_MOVE,follow);
// de functie om de movieclip de muis te laten volgen, de instancename van de movieclip is cursor
function follow(evt:MouseEvent) {
muis.x=mouseX;//muis is de instancename van de movieclip die als muis gebruikt wordt
muis.y=mouseY;
}
// custom muiscursor veranderen in hand zodra je over het knopje gaat
Knopje.addEventListener(MouseEvent.MOUSE_OVER,MuisHand);
// op frame 2 zit het vergrootglas met een extra glow
function MuisHand(evt:MouseEvent) {
Object(root).muis.gotoAndStop(2);
}
// custom muiscursor veranderen in pijl zodra je van het knopje af gaat
Knopje.addEventListener(MouseEvent.MOUSE_OUT,MuisPijl);
// op frame 1 zit het gewone vergrootglas
function MuisPijl(evt:MouseEvent) {
Object(root).muis.gotoAndStop(1);
}
Categories: flash as3, tutorial
Tags: as3, custom, flash, magnify, mask, mousecursor
Comments: No Comments.
Flash AS3 Sound, play, stop and pause [EN]
Click on the radio to start or pause the music. Click on the plug to stop the music. Music by Alphonso Steverink – We are all distorted.
This is the code i used to make the swf above:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | stop(); // declaring variables var pausePoint:Number = 0.00;//Make a pausepoint, for resuming playback var soundClip:Sound = new Sound();//Make a soundobject var sndChannel:SoundChannel = new SoundChannel();//Make a soundchannel var isPlaying = false;//a variable for checking if the music is playing soundClip.load(new URLRequest("name.mp3"));//loading an mp3 into the soundobject StopKnop.addEventListener(MouseEvent.CLICK, onClickStop);//button for stopping the music SpeelOn.addEventListener(MouseEvent.CLICK, onClickPauze);//button to pause or play the music function onClickStop(evt:MouseEvent)//the stop function { if (isPlaying==true)//check if the sound is playing, if true then continue { sndChannel.stop();//stop soundchannel from playing isPlaying = false;//set playing var on false StopKnop.visible = false;//hide the stop button } pausePoint = 0.00;//return pausepoint to 0 } function onClickPauze(evt:MouseEvent)//the pause function { if (isPlaying==true)//check if the sound is playing, if true then continue { pausePoint = sndChannel.position;//remember the pause position sndChannel.stop();//stop soundchannel from playing isPlaying = false;//set playing var on false } else { sndChannel = soundClip.play(pausePoint);//resume playing from pausepoint isPlaying = true;//set playing var on true, sound is playing StopKnop.visible = true;//hide the stop button } } |
To stop all sounds playing on either a timeline or through actionscript, use the following code:
1 2 | import flash.media.SoundMixer; SoundMixer.stopAll(); |
In short, if you would like to play a sound on your timeline use the following code:
1 2 3 4 5 6 | var soundClip:Sound = new Sound();//Make a soundobject var sndChannel:SoundChannel = new SoundChannel();//Make a soundchannel soundClip.load(new URLRequest("name.mp3"));//loading an mp3 into the soundobject sndChannel=soundClip.play();//play the sound |
If you want to re-use this code for more sounds, don’t forget to adjust the var names “soundClip” and “sndChannel”.
It is possible that flash doesn’t play the mp3, depending on the used codec flash can give a streamerror. Use adobe photobooth or audacity to make a new mp3 without any compression. I always use mp3′s instead of other formats. In my opinion those work most of the time.
To stop the above sound from playing use:
1 | sndChannel.stop();//channel stoppen |
Categories: flash as3, tutorial
Tags: as3, flash, sndchannel, sound, tutorial
Comments: No Comments.
3Ds Max Les 1, het kratje
Les 1 van het semester GameArt 3D, maak een kratje in 3D en texture deze via een uvw unwrap. Zie bovenstaande video tutorial voor uitleg over het 3D gedeelte, zorg zelf voor een texture.
Categories: 3Ds max, tutorial
Tags: 3D, 3ds max, kratje, les 1, texture, uvw unwrap
Comments: No Comments.
Flash AS3 timer
Om deze timer te maken heb je de volgende code nodig op het eerste frame van de swf:
var Teller=30; //hierin het aantal seconden dat de timer moet gebruiken
var Tellen=true; // om maar een keer te tellen, zet ik deze nu op true. Later op False, hij is dan al een keer terug geteld naar 0
time_txt.text=Teller; //time_txt is de instance name van het text veld waarin afgeteld wordt. Teller is de variabele met daarin het aantal seconden
var myTimer:Timer=new Timer(1000,30); //1000,30 betekend dat er 30 keer een seconde getimed wordt, aanpassen naar 60 voor een minuut.
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
function timerListener(e:TimerEvent):void {
if (Teller==0) {
Tellen=false; //Niet meer tellen als de teller op 0 staat
} else {
Teller–; //iedere seconde een afhalen van het getal in de variabele Teller
time_txt.text=Teller; //het text vak updaten met het nieuwe getal
//ZwartVlak.nextFrame(); //gaat binnen de instance ZwartVlak naar een volgend frame
}
}
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onComplete);
function onComplete(e:TimerEvent):void {
gotoAndStop(“uit”); //als de timer klaar is wordt dit uitgevoerd, ga naar frame label “uit” in dit geval op frame nummer 2
}
start_btn.addEventListener(MouseEvent.CLICK, onStart);
function onStart(e:MouseEvent):void {
myTimer.start(); //starten van de timer
}
Op frame 2 staat in principe hetzelfde, alleen een donkere laag over alle andere assets heen. Vergeet geen stop(); code toe te voegen voor de zekerheid op frame 2.
Flash AS3 Naam invullen en hergebruiken
Op frame 1 staat deze code:
var Naam=”vul hier je naam in”; //de variabele naam een waarde geven
NaamText.text=Naam;//de var naam in het textveld NaamText (instance name van het inputveld) zetten
NaamText.addEventListener(MouseEvent.CLICK, Leegmaken); //als je klikt op het inputveld, het veld leegmaken
function Leegmaken (e:MouseEvent):void {
Naam=”";//leeg maken
NaamText.text=Naam;//textveld updaten
}
verder.addEventListener(MouseEvent.CLICK, VolgendeFrame);// naar volgende frame
function VolgendeFrame (e:MouseEvent):void {
Naam=NaamText.text;//textveld updaten met de content
gotoAndStop(2);
}
Op frame 2 staat de volgende code (en dat kan natuurlijk ook een willekeurig ander frame zijn):
NaamText2.text=Naam;//textveld vullen met de variabele
